Basic 2d vector question...
Hi, I want to decide if a point is to the right or left of a 2d vector... and haven''t had much luck so far. I sat thinking about it and tried to use a ortogonalvector of the vector. But because I didn''t really now which of the two ortogonals I ended up with it didn''t help me very much... anyone that can point this out to me? I know it''s something small and stupid I''m missing here but can''t say exactly what...
I think that one of the 2D vector multiplications can give you what you need. I think it''s [A, B] = A B sin (A, B), being positive if to the left (or right, depending on your sinus orientation). To calculate the A B sin (A, B) value, the formula is Ax * By - Ay * Bx (or maybe the reverse, sorry about that).
This is an application of the vector product (hint: google search) where the two vectors have a 0 Z-component.
Hope this helps.
Extatica is coming soon!
Check it out on:
http://www.extatica.com02.com
Nexeruza Studios:
http://nexeruza.ionichost.com/home.html
This is an application of the vector product (hint: google search) where the two vectors have a 0 Z-component.
Hope this helps.
Extatica is coming soon!
Check it out on:
http://www.extatica.com02.com
Nexeruza Studios:
http://nexeruza.ionichost.com/home.html
Yes, thanks... I looked up the vector product and thats exactly what I needed.
The answer is right, but the terms are a bit off. (y,-x) in 2D is roughly equavelent to the cross (vector) product in 3D, which it is only actually defined in 3D. You are then taking the dot (scalar) product with that resulting vector. Since cosine is positive on (-pi/2,pi/2) and negative on (pi/2,3pi/2) the sign tells you if the angle between the vectors is greater or less than 90 degrees. Since the dot product is with a vector perpendicular and to the right that says whether it is left or right of the original vector.
Also you have to use a displacement vector not the point. Assuming you are trying to turn an object you need to use the direction from the object to the point rather than from the origin to the point. Otherwise if you are headed straight towards the origin you will turn the wrong direction and only if you are headed directly away from the origin could you be certain of turning the right direction.
Also you have to use a displacement vector not the point. Assuming you are trying to turn an object you need to use the direction from the object to the point rather than from the origin to the point. Otherwise if you are headed straight towards the origin you will turn the wrong direction and only if you are headed directly away from the origin could you be certain of turning the right direction.
Keys to success: Ability, ambition and opportunity.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement