# (Solved) Having trouble dealing with cam rotation~

Anyone can teach me what are a CAM’s : Left Up Direction vectors ?
Are these three vectors must be orthogonal ?
If i used cam.getUp cam.getLeft cam.getDirecton , did i get a normalized vector?

BTW I’m working on a cam control (move rotate raise ) parallel to the x-y plane.

1 Like

The direction vector is the central axis of the camera’s view. If you put your mouse dead center in the camera’s view and shoot a ray into the scene, that ray will travel along the camera’s direction vector. In other words, it’s the center of your field of view.

The left and up vectors are used to orient the camera’s local coordinate space. If something is expressed in screen space coordinates, they determine how it appears relative to the view. In jME, left is -X and up is +Y.

Logically, if you consider the camera in world space then the left, up, and direction vectors appear to be orthogonal BUT they are not because the left and up vectors are not in world space. If you do a cross product with them, in general you will not get the direction vector. In world space the cross product will look like the direction vector (or the negative of the direction vector) but the coordinate components won’t be at all the same because they’re in a different coordinate system (the camera’s local coordinates).

I’m not sure if jME keeps these normalized or not. In general, if your calculations require normalized vectors I’d suggest always normalizing a vector before you use it for two reasons: (a) it’s more robust - if someone comes along and changes a normalized vector in the engine to an unnormalized vector (on purpose or via a bug), your code remains unaffected, and (b) it makes your intent in your code clear - you have permanently indicated in your code that your calculation requires vectors to be normalized, and if you or other developers go back and visit that section again they will immediately see that you thought the vectors should be normalized, which can go a long way towards clearing up confusion if someone isn’t sure what a calculation should be doing.

1 Like

Camera direction vectors will be normalized unless you change them yourself.

The represent the coordinate axes of the camera… which google will have a TON of articles on if you are interested in more information than that.

Aside: a 3x3 orientation matrix is essentially the three orthogonal coordinate axes.

1 Like

Thank you guys

1 Like

This picture will give you a visual representation of what you need to know about a 3D Rendering Camera and its vectors.

Also read this tutorial from the wiki:

2 Likes

Note that that picture is of an orthogonal camera, not a perspective camera.

1 Like

One more question :
What if I input Up-Left-Direction vectors that they are not orthogonal ?
for example :
Up: 0,0,1
Left-1,0,0
Direction: 1,1,1 (not orthognonal to UP-Left plane)

1 Like

Yes, those are orthogonal.

But in a perspective camera, the frustum sides are not parallel to any axis vector.

1 Like

You’re right in that by the usual dot-product-is-zero metric, those vectors are not orthogonal. However… they are orthogonal in a sense because they are in separate spaces. The direction vector is in world space, but the up and left vectors are in camera space (in fact, they define the orientation of camera space - a left vector of (-1, 0, 0) means that moving one unit in the -X direction moves left across the camera’s view). Here’s the gotcha… since the direction vector determines where the camera is looking in the world, it must be orthogonal to the camera’s viewing plane. If you transformed it into camera space, it would lie along the camera’s forward axis and thus, when dotted with the up and left vectors, would have a dot product of zero (truly orthogonal in the mathematical sense). Vector spaces are a bit hard to wrap your head around at first, but once you get used to using this stuff it will become second nature quickly.

1 Like

Ignore me. I completely misread the question.

If you give the camera non-orthogonal vectors then you create a strange world transform and will get odd results.

In JME, the Camera.setUp(), setLeft(), setDirection() are all in world space and should all be orthogonal to each other.

Edit: actually, JME is wise and doesn’t let you set these at all. They are byproduct of the proper transform methods already on Camera.

1 Like

Ignore me too… I assumed the up and left vectors were in camera space, but from @pspeed’s answer this is not the case in jME.

1 Like

Thank you ~

1 Like