Archived

This topic is now archived and is closed to further replies.

Erik23a86

problems understanding vector classes

Recommended Posts

I have a problem understanding the vector classes used for Collision detection. For example this vector class for the rayplaneCollision tutorial from www.gametutorials.com. struct CVector3 { public: float x, y, z; }; CVector3 Cross(CVector3 vVector1, CVector3 vVector2); CVector3 Vector(CVector3 vPoint1, CVector3 vPoint2); float Magnitude(CVector3 vNormal); CVector3 Normalize(CVector3 vNormal); CVector3 Normal(CVector3 vTriangle[]); I know wat verctors are. A vector has got a magnitude and a direction. The thing I don''t understand is why there is no direction in the vector class. There are only co-odinate of one point. Please help me understand. Thanks. The One.

Share this post


Link to post
Share on other sites
x,y,z is the direction, i.e., a ray originating from [0,0,0] to [x,y,z].

sqrt(x*x+y*y+z*z) is the magnitude, i.e., the distance from [0,0,0].

[edited by - smart_idiot on January 6, 2004 6:07:04 AM]

Share this post


Link to post
Share on other sites
So, there are extualy two points, a static point with the co-ordinates 0,0,0 and a variable point with the x,y,z from the vector class. I understand it now . I knew there must be two point in order to get the direction of the vector, but I was not certain that the second point was 0,0,0.
Is this methode used in most of the vector classes?

Thanks.

The One.

Share this post


Link to post
Share on other sites
Well, actually you don''t need a second point at all, that is the nice thing with vectors, they are independent of the origin. Perhaps someone has a nice tutorial concerning vectors for you.

Share this post


Link to post
Share on other sites