How do I calculate a vector perpendicular to a vector?
It is for some easy camera positioning -- creating a 2d game, need the camera to go out perpendicular from the player to a certain distance and stay there.
Printable View
How do I calculate a vector perpendicular to a vector?
It is for some easy camera positioning -- creating a 2d game, need the camera to go out perpendicular from the player to a certain distance and stay there.
A vector can have an undefined amount of perpendiculares. You have to have a "surface" to find a perpendiculare. IE. Two vectors forming a plane.
ØØ
Well if you are willing to aid a bit.
Remember mario? assume it was a 3D game and the screen scrolling was actually the camera moving. I need to know how to position my camera like that.
The player moves in the x,y plane -- I need the camera to stay at a certain z distance. Normally this would be easy, but now and then I allow the player to move in all 3 dimensions -- when that movement stops I need to once again calculate the perpendicular of the player position and move the camera accordingly.
Edit: heh, Well I guess this belongs in a different section now.
A vector perpendicular to a plane given by two vectors is its cross product. If you only have one vector given then any other vector will do.. of course i'm not sure what you meant here, since i haven't played mario, cept those good old snes ones
Hmm....
i'm guessing you have a point in the X-Y plane (X, Y, 0), and want to position the camera in another X-Y plane, but raised a certain Z distance....
this would just be at (X, Y, Zdistance) then....
maybe i don't undertand...
I am guess he want a Tomb Raider follow head camera. That camera is using Quaternions, and I can't see why he needs the perpendicular for that.
A good tutorial that is independent on what API you are using is this one. Happy reading...;)
http://www.gamedev.net/reference/art...rticle1927.asp
In 2D, the negative reciprocal of the slope will do.
Y = m X + b
The line with slope m1 is perpendicular to the line with slope m2
m2 = -1/m1
In multi-dimensions (and 2D), the dot product of the two vectors will be zero if the vectors are perpendicular.
My camera is using Quaternions.
I enjoy all your comment I believe from thus I can solve it.
Edit: Tomb Raider was a terrible game -- of its genre - which I love, it was probably the worst. Its camera was most annoying.
Yeah but get in the right position and you can get a good view of her pixellated bum, that was all the fun I had in 1996 :D.Quote:
Originally Posted by Halsafar
I had Tifa and FF7 :)
or
Celina from SO2 heh
and of course my SNES which I made lots of non-literal love to. :afrog: