Qbasicnews.com

Full Version: Determining a perpendicular vector off one vector.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Let's say I have would want a transformation matrix that looks like this:

Code:
[  v1.x  v1.y  v1.z ]
[  v2.x  v2.y  v2.z ]
[  v3.x  v3.y  v3.z ]
Which I wan't to transform my world coordinates with. And I know the values of V1.

How would I go about getting V2(short of guessing). If I can get V2, V3 won't be a problem as I would only get the Cross-product between V1 and V2 as I need the three to be prependicular to each other much like the X,Y and Z axes.

Reasons why getting two is giving me problems.

1. Geometry would tell me that "There are infinite number of lines that can pass though a *single* Point" And considering another theorem would tell me: " The intersection of 2 lines is a POINT", the above problem is not mathematically correct since there could be an infinite number of perpendicular vectors from V1. :*(

2. Trig somehow would give me a workaround as there is no normal to a line/vector when in 3d space. A normal could only be defined from a plane. This again would give me problems trying to define the orientation of a plane that contains V1 and perpendicular to V2.


I case you're wondering, I'm making my own Lookat function which would eiminate all the rotation matrices off my engine. Therefore, making the engine very flexible. I have made a working Lookat function using a tute but need a better transformation matrix.

Anty links or articles is welcome. Thanks!!!!

Here's lil demo:

http://forum.qbasicnews.com/viewtopic.php?t=6193
I apoligise if this is not what you are looking for, as I only understand a small part of what you just wrote, but If you want to fin a perpendicular vector, the Dot product of the vector and the vector perpendicular to it is 0.

I would have thought you would have known that, so is the problem actually getting the other vector from the equation?

I mean

in component form:
(x1*x2)+(y1*y2)+(z1*z2) = 0

Sorry if you already knew that =P
So you know one vector in a certain direction.
And you want two other vectors wich are both perpendicular to that vector eh? Sort of redefining your axes. ??

The only way is to know this is from external data like at what angles does the camera look.

Ok lets say your camera stands in a certain direction, we call this direction vector 1.

The only way to find the other two vectors is from a known geometry. What you'll have to do is quite easy.

Just define an object of the 3 axes vectors (1,0,0) (0,0,1) and (0,1,0)
Then rotate the object in the desired direction using rotation matrices (I suppose you know how to do that)
Thus you define the three axis in the 3d object and the rotate the entire object.

Thats all.
Turbo:

That's what I was using. An axis based rotation. I could define my camera as an inverse of that and I would be fine. But what I wan't is to make my own lookat transform. A lookat transform basically doesn't use the angle system. example:

Lookat(300,523,745)
That would be v1 our forward vector. I wan't to find the right vector and then the up vector would be a cinch.


Ie.

1. I could get v1 by using either the spherical or cylindrical coordinate system.

2. this I don't know.

3. Now for v2 I would just Cross(V1,v2,v3) where v3 is the normal defined by v1 and v2.

4. Plug those vectors at the above matrix and transform my points.


Dark: The dot(scalar product) returns a scalar value(cosine of angle). I want a vector which means the cross product (vector product)

I have a working lookat transform at home but I wan't to know other lookat transforms.

Like:

target-cam
Thanks!!! Just what I needed.