views:

142

answers:

6

Hey Guys,

I'm confusing myself terribly grasping the concept of plotting on a 3D plane, if I'm looking down the -Z axis, to put an objectinfront of me I just make the Z value Negative and to put it behind I just make it positive.. but.. how do I Put objects to my left or right? Sorry, I realise this is a stupid question but none the less it's confusing me

Example

I'm drawing a square at (-3,-2,10; -3, 2, 10; 3,-2, 10; 3, 2, 10) how would I draw something to its right or left hand side?

+3  A: 

The X axis defines the left-right dimension, the Y axis defines the up-down dimension, with negative values to the left and down, positive values to the right and up. So offset your drawing in the positive x direction (i.e. add some value to all of the x values in your square) to move it to the right.

bshields
+2  A: 

Keep the Z-axis the same, and move on the X-axis.

left and right is subjective offcourse, because it depends how you view it, but I assume you are looking flat at the x-y axis, and the z axis is "pointing away" from you.

So, in your case: (-3+a,-2,10; -3+a, 2, 10; 3+a,-2, 10; 3+a, 2, 10) where a is how much you want to move it to the right

if you make a negative, it will shift to the left (on the X axis).

Because your starting point is -3, and your end point is 3, your Y-axis will be in the middle of your object. so your starting point should be 3, and endpoint 9 te be to the right of the object. -> a=+6

if you want to go to the left: (starting-point-previous-object) - (width of object) = (-3)-(6)=-9 -> a=-9

To rotate objects

watch this website it has a ver simple and basic explanation. I find it to be very readable

Nealv
so, if I wanted to move it 90 degree's to the right what value would I give x?
Ulkmun
For a right handed coordinate system, z would generally be coming out of the screen, so the viewer is looking down the -Z.
bshields
@bshields: very true, @Meowix: you dont move shapes with degree's, you rotate them.If you want to rotate you should use sine and cosine http://en.wikipedia.org/wiki/Trigonometric_functions
Nealv
if you want to rotate, around what do you want to rotate? the plane around one of it's corners, or it's center ? ... Or the pint where your axis' start
Nealv
+3  A: 

I drew something like this on a piece of paper:

Draw + and - onthe ends of the axis. Helps keep track while punching in numbers.

In your case, it would be -Z moving away from you, or "into" the screen.

Neil N
This is DirectX coordinate system (left-handed). In OpenGL(right-handed), when X points right and Y points up, Z axis points towards the viewer.
SigTerm
@SigTerm: There is no "DirectX coordinate system" Both DirectX and OpenGL can use either left handed or right handed.
Neil N
@Neil N: "Both DirectX and OpenGL can use either left handed or right handed" This is not exactly correct. By default DirectX uses left-handed, OpenGL uses right handed. It is possible to make API use different system, but it requires additional steps. Normally - flipping z in projection matrix, and changing triangle vertex order(cw vs ccw). Or switching face culling rule.
SigTerm
@SigTerm: no, it is exactly correct. Both API's handle both coordinate systems.
Neil N
@Neil N: Whatever.
SigTerm
A: 

Your coordinates are (x,y,z).

You have described translating the square in the z plane by changing the z values.

Moving left or right is a translation in x - simply offset the x values.

Moving up and down is a translation in y - simply offset the y values.

morechilli
+1  A: 

Well, in a three dimensional cartesian coordinate system, you have three perpendicular axis X, Y and Z.

Directions like right, left, top or front though are always subjective and can just be interpreted in relation to a camera. All operations with these coordinates (rotation, translation, vector maths in general) is independent of this view.

Now if you define a camera, you have defined the directions as well. A common definition (like used in DirectX) is the camera

  • resides in the origin
  • looks along the Z-axis
  • has an upward direction along the Y-axis

Therefore right/left is defined through positive/negative X coordinates, same for up/down with Y or front/backwards direction on the Z-axis.

But this is never an absolute thing. Given another camera (e.g. rotated, moved), all looks different. Just look how things move when you look on them upside down.

This image shows pretty well how it all depends on the camera (why can't Stackoverflow handle .svg-graphics?)

Dario
A: 

Regarding the coordinate system used : Most textbooks use the right-handed. A few outcomers (DirectX, PBRT) use a left handed one.

In a right-handed coordinate system, your thumb is the x. The following axes come in the same order as the other fingers (Y = index, ...).

Now move your hand so that X is towards the right of the screen, Y is up, and Z is towards you. This will be how OpenGL "sees" the world.

That's pretty much all you need to know.

Calvin1602