# Min/Max of two vectors?

This seems like a simple question, but i'm having trouble searching the internet for it.

In XNA, during a collision detecting method, I would determin the minimum of some vectors.

``````// Get the minimum top point
Vector2 minTopPoint1 = Vector2.Min(topLeft1, topRight1);
// Get the minimum bottom point
Vector2 minBottomPoint1 = Vector2.Min(bottomLeft1, bottomRight1);
// Get the minimum of both the top and bottom points.
Vector2 minPoint1 = Vector2.Min(minTopPoint1, minBottomPoint1);
``````

I switched over to making a C++ engine, and am trying to replicate the collision formula (Honestly, it's confusing enough, I just need to replicate it from XNA) I made my own Vector2, and now I need to make this Min function.

So, what is the minimum or maximum of two vectors? Is it just the magnitude of the two vectors measured against eatchother? Is it the x and y values min/maxed somehow?

-
It is always a good idea to check the documentation on the method if you want to know what it does: "Returns a vector that contains the lowest value from each matching pair of components." msdn.microsoft.com/en-us/library/… – Jay Lindquist Dec 30 '12 at 3:57
Thanks, I did look at the documentation first, but it was still unclear what it did from that description. To me, at least. – MintyAnt Dec 30 '12 at 5:59

The code behind all the methods in Xna are available with reflection (I use red gate's reflector application but there are probably free ones). here's the code behind `Vector2.Min`

``````public static Vector2 Min(Vector2 value1, Vector2 value2)
{
Vector2 vector;
vector.X = (value1.X < value2.X) ? value1.X : value2.X;
vector.Y = (value1.Y < value2.Y) ? value1.Y : value2.Y;
return vector;
}
``````
-
That's nuts. It could be a new vector, not one of the old vectors. See now im more confused about this damned collision detection junk! – MintyAnt Dec 29 '12 at 20:33
Side note: Telerik's JustDecompile is a really nice alternative to Red Gate's Reflector. telerik.com/products/decompiler.aspx – Inisheer Dec 29 '12 at 21:06