Skip to main content

Which way does the view face (by default)? Or, SpaceShipBehavior

2 replies [Last post]
scottval
Offline
Joined: 2009-10-16
Points: 0

I was wondering which way the view faces, by default. I.e., does the "eye" of the view point along the x-axis, the y-axis, or the z-axis? (Given an identity transform.)

It would make sense for the view to point along the x-axis, with the y-axis on the "right" and the z-axis "up." Wouldn't it?

I wrote a small program to see for myself which way the view was facing. To my surprise, I found that it was facing in the negative-z direction, with the x-axis on my right and the y-axis up. That seems kind of odd. Can anyone confirm this?

I became interested in this question because I was attempting to better understand how rotations work. I wanted to start with an identity transform, and then rotate it in different directions. I wanted to calculate the roll, pitch and yaw. I also wanted to calculate which way was "forward" (relative to the view) and which way was "right" and "up," for any rotation.

Ultimately I'd like to create a SpaceShipBehavior, which would allow a view to act like a space ship, with six degrees of freedom. The tricky part seems to be moving the space ship "forward" and "right" and "up" (relative to the space ship) for any rotation. (Is there a SpaceShipBehavior out there?--I couldn't find one.)

So I decided to get down to basics, starting with the question, which way does the view face? And the answer seems to be: negative z. up=y.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mikelizzi2
Offline
Joined: 2011-10-13
Points: 0

Yes, as you figured out, the default orientation in Java 3D is the positive x-axis to the right, positive y-axis up and positive z-axis coming out of the screen. I was initially surprised to see this myself. Then I realized that's the way 3d axes are defined in engineering and physics.

Note: From the user point of view, a positive rotation in the XY plane would be counterclockwise. Similarly for the other planes.

scottval
Offline
Joined: 2009-10-16
Points: 0

Mike,
Thanks for the reply. Yes, that makes sense now.

I think the key to keeping track of forward, right and up relative to the view (remember I'm a space ship) is to have a normalized vector for forward, and another for right and another for up. I would multiply the vectors by the rotational transforms. If I want to translate in a particular direction (forward, etc.), the components of the vector would give me the actual x-y-z translation.

Scott