projection matrix from front vector

Posted By: mk_1

projection matrix from front vector - 08/24/11 15:16

Okay, here's the problem: I have an arbitrary 3D vector based on a position and target which is my front/view vector.
I need a second vector (up vector) perpendicular to the view vector which direction is based on an orientation value -pi to pi. For orientation = 0 it shall be coplanar with the view vector pointing upwards, i.e. the orientation value depicts a rotation around of the up vector around the view vector. Any ideas how to calculate this?
Posted By: Slin

Re: projection matrix from front vector - 08/24/11 15:47

I am not sure if I understand it correctly, as I somehow stopped thinking after the first sentence. But is this what you want? http://stackoverflow.com/questions/349050/calculating-a-lookat-matrix
Posted By: lostclimate

Re: projection matrix from front vector - 08/24/11 16:29

i thought you just needed the up vector at first but i stopped getting what you said once you got to the pi part. is that all you need to do is calculate the up vector?
Posted By: Joey

Re: projection matrix from front vector - 08/24/11 23:11

coplanar with the view vector pointing upwards... which plane are you talking about? what is up?
Posted By: mk_1

Re: projection matrix from front vector - 08/24/11 23:22

I was indeed not very clear on what I meant.
Basically I want to construct a lookAt-matrix BUT I don't want the up vector always pointing upwards. Here's what I want to do:

I need a matrix to project a decal so you have a projection source and a target. So far so good, I can use a normal lookAt-matrix but the point is that I want to rotate the decal on the ground, i.e. my up vector is not always (0,1,0) but should rotate around the view vector based on some orientation value. Kinda hard to explain. Maybe I can make a video tomorrow

EDIT: Coplanar meaning on one plane with the view vector so that the view and up vector span a plane (for orientation = 0 this would be the Y-axis (pointing upwards))
Posted By: Slin

Re: projection matrix from front vector - 08/25/11 13:54

What about:
Up (0.0, 1.0, 0.0)
Right (1.0, 0.0, 0.0)
Front (0.0, 0.0, 1.0)

And then just rotating them?
Or if you already have the front vector, it shouldnt be a problem to rotate some vector around it, problem here is just to choose one of the endless possible vectors...
Posted By: mk_1

Re: projection matrix from front vector - 08/25/11 15:33

Nvm, I got it. Part of the problem was that I didn't have any rotations. Also I had problems to construct a right vector when the up and front vector were parallel (which is somehow logical since there're endless possibilities for the right vector).

Thx all for your help
© 2024 lite-C Forums