• Create Account

## Support Vector

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

11 replies to this topic

### #1Gavin Williams  Members

Posted 01 April 2014 - 02:57 AM

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, 01 April 2014 - 11:53 AM.

### #2Álvaro  Members

Posted 01 April 2014 - 03:03 AM

I don't think "support vector" means anything without context. Do you have a definition or something else we can work with?

### #3Gavin Williams  Members

Posted 01 April 2014 - 03:13 AM

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.

### #4Javier Meseguer de Paz  Members

Posted 01 April 2014 - 05:14 AM

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

### #5Doublefris  Members

Posted 01 April 2014 - 09:27 AM

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.

### #6Dirk Gregorius  Members

Posted 01 April 2014 - 10:26 AM

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, 01 April 2014 - 10:28 AM.

### #7Gavin Williams  Members

Posted 01 April 2014 - 11:41 AM

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

### #8Buckeye  GDNet+

Posted 01 April 2014 - 12:18 PM

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

### #9ferrous  Members

Posted 01 April 2014 - 05:18 PM

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, 01 April 2014 - 05:19 PM.

### #10Javier Meseguer de Paz  Members

Posted 01 April 2014 - 06:08 PM

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

### #11Gavin Williams  Members

Posted 02 April 2014 - 08:36 AM

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

### #12Álvaro  Members

Posted 02 April 2014 - 09:03 AM

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.