0
votes

My math is too rusty to figure this out. I want to derive the onscreen angle (the angle as seen on the 2d screen) of a 3d vector.

Given the x and y rotation of a vector (z rotation is zero and doesn't mstter), what does the angle on screen look like?

We know when y is zero and x is positive, the angle is 90. When y is zero and x is negative the angle is -90. When y is 90, for any value of x, the angle is 180. When y is -90, for any value of x, the angle is 0.

So what the formula here so I can derive the angle for the other values of x and y rotation?

3

3 Answers

1
votes

The problem, as stated, doesn't make sense. If you're holding z to zero rotation, you've converted a 3D problem to 2D already. Also, it seems the angle you're measuring is from the y-axis which is fine but will change the ultimate formula. Normally, the angle is measured from the x-axis and trigometric functions will assume that. Finally, if using Cartesian coordinates, holding y constant will not keep the angle constant (and from the system you described for x, the angle would be in the range from -90 to 90 - but exclusive of the end points).

The arctangent function mentioned above assumes an angle measured from the x-axis.

0
votes

Angle can be calculated using the inverse tangent of the y/x ratio. On unity3d coordinated system (left-handed) you can get the angle by,

angle = Mathf.Rad2Deg * Mathf.Atan(y/x);
0
votes

Your question is what will a 3-d vector look like.

(edit after posted added perspective info) If you are looking at it isometrically from the z-axis, it would not matter what the z value of the vector is.

(Assuming a starting point of 0,0,0)

1,1,2 looks the same as 1,1,3.

all x,y,z1 looks the same as any x,y,z2 for any values of z1 and z2

You could create the illusion that something is coming "out of the page" by drawing higher values of z bigger. It would not change the angle, but it would be a visual hint of the z value.

Lastly, you can use Dinal24's method. You would apply the same technique twice, once for x/y, and then again with the z.

This page may be helpful: http://www.mathopenref.com/trigprobslantangle.html

Rather than code this up yourself, try to find a library that already does it, like https://processing.org/reference/PVector.html