Advertisement Jump to content
Sign in to follow this  
Gavin Williams

Support Vector

This topic is 1751 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

 

Is the following function for a support vector correct?

class Vector2
{
     public Vector2 SupportVector()
     {
         if (Math.Abs(X) > Math.Abs(Y))
             return new Vector2(X, 0);
         else
             return new Vector2(0, Y);
     }
}
Edited by Gavin Williams

Share this post


Link to post
Share on other sites
Advertisement
I don't think "support vector" means anything without context. Do you have a definition or something else we can work with?

Share this post


Link to post
Share on other sites

Oh right, so I'm working on a physics engine ... contact normals. I've read about support vectors, but I can't find a definition, or code. I'm assuming a support vector is the orthogonal projection with greatest influence on V.

Share this post


Link to post
Share on other sites

I'm sure it would help us if you gave name to letters. What's X and Y in your function? (I mean, coordinates of what?). What's V in your latest post?

Share this post


Link to post
Share on other sites

The support point is the furthest (extreme) point in a given direction:

int Support( const std::vector< vector2 >& vertices, const vector2& vDirection )
{
  float flBestDistance = -FLT_MAX;
  int nBestVertex = -1;

  for ( int nVertex = 0; nVertex < nVertexCount; ++nVertex )
  {
    float flDistance = DotProduct( vertices[ nVertex ], vDirection );
    if ( flDistance > flBestDistance )
    {
      flBestDistance = flDistance;
      nBestVertex = nVertex;
    }
  }

  return nBestVertex;
}
Edited by Dirk Gregorius

Share this post


Link to post
Share on other sites

@Javier - The X and Y are the x and y ordinates of a Vector2, this is c#, not c++, so a Vector is a geometric vector, not an array, or anything like that.

 

I wanted to make sure that i was using the right terminology, but it seems from the mixed responses that there is no single definition, and it can mean any number of things. I'll just call it a support vector for now.

 

Thanks all.

Share this post


Link to post
Share on other sites

@Javier - The X and Y are the x and y ordinates of a Vector2, this is c#, not c++, so a Vector is a geometric vector, not an array, or anything like that.

Editing your posted code and then criticizing a previous response is bad style. Your original post did not define X or Y or provide any context.

Share this post


Link to post
Share on other sites

In a Vector2, X and Y seem fairly obvious.  Support Vector, the definition seems a bit different than how Dirk defined it (I kinda love that someone mentions the GDC slides of someone, and then that someone then replies to the thread).  If you're looking for the vector orthogonal, that's not right.

 

Vector2 perpVector = new Vector2(-Y, X);  (or the negative of that for the other direction, and I'd have to double check, but that first one is the 'left' vector, the negative is the 'right' vector, if you consider the existing vector to be 'forward')

Edited by ferrous

Share this post


Link to post
Share on other sites


In a Vector2, X and Y seem fairly obvious.

 

Sure, but at the first version of your post the SupportVector function was not inside a Vector2 class. It can be seen in your post's history: http://www.gamedev.net/index.php?app=forums&module=extras&section=postHistory&pid=5143649. I imagined they were components of a vector, but even if they were I had no clue about what that vector would be. Saying something is a vector is as useful as saying something is a number. Both entities have no meaning by themselves...

 

Anyway, this doesn't contribute to the subject. I hope the answers you have are what you were looking for.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!