Perpendicular vectors
Blitz3D Forums/Blitz3D Programming/Perpendicular vectors
| ||
The fastest way to obtain the two vectors perpendicular to a known vector? (it sounds like the inverse of the cross product :) ) precisely however i'd need the 4 points of the cross resulting from these 2 vectors (p1,p2,p3,p4) ![]() thx |
| ||
Not sure I understand - there's an infinite number of vectors perpendicular to a single vector (imagine the cross in your pic rotating). |
| ||
but they lie on the same plane In theory I should choose a random value and do a cross product with the other vector generated by the new point. |
| ||
Ah, so you don't care about the orientation of the vectors? Then I guess you can calc a normal to the vector, and then calc the cross prod of these two vectors to find the 3rd vector. |
| ||
the only thing I have is the green vector |
| ||
I understand that. :) What I'm saying is: - calculate a normal to the green vector (sorry, I don't know how to do this off the top of my head). - calc cross prod of green vector and normal to get 3rd vector. |
| ||
Easy way, create a pivot, align it's Y axis to the vector you know, then use tformpoint to find -X, +Z, +X, -Z (-1,0,0 - 0,0,1 - 1,0,0 - 0,0,-1) The hard way, in psuedo code: vecY = 1,2,3 ;your known vector normalize vecY ;use any vector that isn't vecY vecZ = 0,1,0 if vecZ = vecY or vecZ = -VecY then vecZ = 0,0,1 ;can't crossProduct parallel vectors ;find a perpendicular vector, vecX, from vecY & vecZ vecX = crossProduct(vecY,vecZ) ;orthoganalize vecZ (this just rotates vecZ around the vecX axis until it's perpendicular to vecY) vecZ = crossProduct(vecX,vecY) normalize vecX normalize vecZ ;in clockwise order around vector vecY, 4 points lying on the plane X,Z would be -vecX vecZ vecX -vecZ |
| ||
nice the first solution :D thanx! |