Support Vector

Started by
10 comments, last by alvaro 10 years ago

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);
     }
}
Advertisement
I don't think "support vector" means anything without context. Do you have a definition or something else we can work with?

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.

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?

“We should forget about small efficiencies, say about 97% of the time; premature optimization is the root of all evil” - Donald E. Knuth, Structured Programming with go to Statements

"First you learn the value of abstraction, then you learn the cost of abstraction, then you're ready to engineer" - Ken Beck, Twitter

I think you mean the support vertex, which is the max dot product of a particular direction vector with the vertices of a (convex) polygon A.

Look at Dirk Gregorius 2013 slides, he explains it well.

https://code.google.com/p/box2d/downloads/list

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

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

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

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

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')


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.

“We should forget about small efficiencies, say about 97% of the time; premature optimization is the root of all evil” - Donald E. Knuth, Structured Programming with go to Statements

"First you learn the value of abstraction, then you learn the cost of abstraction, then you're ready to engineer" - Ken Beck, Twitter

This topic is closed to new replies.

Advertisement