Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
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.
Posted 23 August 2009 - 08:43 PM
Posted 23 August 2009 - 08:49 PM
float CMath::Angle( const CPoint* a, const CPoint* b)
{
return ToDegrees( atan2( b->y - a->y, b->x - a->x ) );
}
float CMath::Angle( const CPoint* b)
{
CPoint a(0,0,0);
return Angle( &a, b );
}
float CMath::ToDegrees( float radians )
{
return radians * DEGREES_PER_RADIAN;
}
float CMath::ToRadians( float degrees )
{
return degrees * RADIANS_PER_DEGREE;
}
Posted 23 August 2009 - 09:02 PM
Posted 23 August 2009 - 09:16 PM
Quote:
Original post by phresnel
How exactly do you define "angle between points"?
Points are dimensionless entities with no direction in any n-space. The only sane measure between two points that I am aware of (at 10 in the morning) is distance.
Possibly you mean angle between vectors?
Posted 23 August 2009 - 10:16 PM
Quote:
Original post by shadowcomplex Quote:
Original post by phresnel
How exactly do you define "angle between points"?
Points are dimensionless entities with no direction in any n-space. The only sane measure between two points that I am aware of (at 10 in the morning) is distance.
Possibly you mean angle between vectors?
Often (and incorrectly so), points and vectors are used interchangeably in game dev, especially 2D game dev. Basically considering a point to be a vector originating from the origin. I've seen this from indies, hobbyists, and commercial shops :)
This becomes a nuisance eventually, though, with "w" values. For the most part, 2D games can save on some code by having a joint "point"/"vector" class, even though it is amathematically incorrect model :D
So in the OP's case, it's really mapping one origin vector to another and determine the angle between them.
Point A, B;
...
Vector direction = B-A;
float length = direction.length();
Point newP = A + direction * 3;
Posted 23 August 2009 - 11:07 PM
Quote:
Original post by phresnel
I think it is only beneficial to seperate those models (and comes at no extra runtime cost), as I made the experience that it makes code clearer (i.e. intentions) and less error prone (operations that don't make sense are forbidden). Some operations are also distinct, dependent on whether the underlying concept is point, vector, or normal.
As you see, it already confused me to see some angle between points, which only makes sense if we assume some coordinate origin to both.
To give an example of how I am used to it:
Point A, B;
...
Vector direction = B-A;
float length = direction.length();
Point newP = A + direction * 3;
Point+Point is not defined, Point-Point yields a Vector, Point[+-]Vector yields a new Point, et cetera.
In picogen, the distinction is important for yet another reason: Points and Vectors are allowed to use different scalar types. I need this so that I can use fixed-point arithmetic for points, but floating point math for directions. Thanks to that distinction and the thorough constraints upon Points (operator+, operator-, distance), only the most basic fixed point math is needed (addition, subtraction, comparison).
...
Probably I am just too drilled by writing ray tracers, where the mathematical model is often common ;)
Posted 24 August 2009 - 01:06 AM
Quote:I'm not going to try to answer the question from a rigorous mathematical perspective, but I will say that yes, in practice, points are often considered as displacements from the origin in the context of games and graphics programming.
Sorry, but I dont understand the distinction between a vector and a point. Isn't a point just a vector from <0, 0> ?
Quote:Not really. Whether you're using separate point and vectors classes or using a vector class to represent both vectors and points, it's still important to use correct terminology when talking about geometrical problems.
I would have thought specifying points in 2D space would have made it obvious that I meant 2D vectors :)
Posted 24 August 2009 - 01:08 AM
Quote:
Original post by _Sauce_
Sorry, but I dont understand the distinction between a vector and a point. Isn't a point just a vector from <0, 0> ?
Posted 24 August 2009 - 01:20 AM
Posted 24 August 2009 - 01:47 AM
Posted 24 August 2009 - 02:01 AM
Posted 24 August 2009 - 02:10 AM
Quote:
Original post by Interesting Dave
GPS would give a point = position = location, right?
the GPS co-ordinates for new york and sydney can be used with atan2 to get the angle between them (angle between two points).
Or are we saying that GPS should actually be called Global Vectoring System (/Satelites)?
Posted 24 August 2009 - 02:12 AM
Posted 24 August 2009 - 02:24 AM
Quote:
Original post by Interesting Dave
Or are we saying that GPS should actually be called Global Vectoring System (/Satelites)?
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.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.