Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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."… – 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
up vote 6 down vote accepted

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;
share|improve this answer
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. – Inisheer Dec 29 '12 at 21:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.