Sign in to follow this  
Gavin Williams

Support Vector

Recommended Posts

Gavin Williams    985

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
Gavin Williams    985

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
jmpep    375

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
DonDickieD    2751

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
Gavin Williams    985

@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
Buckeye    10747

@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
ferrous    6137

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
jmpep    375


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
Gavin Williams    985

 

@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.

 

 

Sorry if it sounded like a criticism, I didn't mean it as a criticism. I meant it as a clarification. And i edited the question to clarify what X and Y are. Though I can see that such an edit then degrades the clarity of the conversation.

Share this post


Link to post
Share on other sites
alvaro    21246

 

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);
     }
}

 

I would call that function something like `LongestProjectionToCoordinateAxis'.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this