Space geometry

Started by
2 comments, last by linus78 21 years, 11 months ago
Hi, I have a problem with coordinates in a cube. Say that i have a cube that is 1unit x 1unit 1unit big. Ill place the origo in the centre of the cube. With help from two angles I can point to any place of the surface of the cube. The angles are called azimuth and elevation. Azimuth rotates around the Z axis and elevation rotates aound the X axis. So my problem is: If I know the two angles how do I calculate the point on the surface (x,y,z)? Thanks, Linus
Advertisement
Look at spherical coordinates, and once you have a vector in the correct direction, intersect this vector with your wall planes. I don't know spherical coordinates very well, so I won't try to explain how to convert your two angles into a vector, but I can help with the second part:

Let's say that your vector is in the direction (a,b,c).

If |a| > |b| and |a| > |c| and a > 0 then your point falls on the right side of your cube. In that case, you know that x = 0.5 (half the width), so
P = (0.5, b / a * 0.5 , c / a * 0.5)

If a < 0, then it's on the left side and x = -0.5.

The trick is to find the largest value of (a,b,c) and check its sign.

Cédric

[edited by - cedricl on April 28, 2002 7:36:16 PM]
Ok, here goes.

Elevation (I will call it E) will tell your your Z value. You know the axial distance from the origin to any side (0.5). We can assume things about the height according to the angle:
[45°,135°], Z = 0.5
[225°,315°], Z = -0.5

All other angles have to be calculated. You can use tangeant with the angle to find the Z value. We form a triangle, where we know the base length (0.5) and the angle (Elevation). Tan(E) = Z / 0.5. Z = Tan(E) * 0.5. Remember first to check the angle limits.

Next we have Azimuth (I will call that A ). This angle has to find the X and Y values. We can use angles capping again. This time its more complex, since we have two coordinates to find:
[45°,135°], Y = 0.5, must find X
[225°,315°], Y = -0.5, must find X
[225°,45°/405°], X = 0.5, must find Y
[135°,225°], X = -0.5, must find Y

From this we can conclude that at 45°, 135°, 225° and 315° both X and Y are ±0.5. The sign depends on the quadrant:
             90°              |        -X    |  +X        +Y    |  +Y180° ------------------- 0°        -X    |  +X        -Y    |  -Y              |             270°    


Values can be calculated the same way as with E. When you need to find X, Tan(A) = 0.5 / X, X = 0.5 / Tan(A). When we need to find Y, Cot(A) = 0.5 / Y, Y = 0.5 / Cot(A).

Hope that was all correct and made sense!

[edited by - Zipster on April 28, 2002 10:10:09 PM]
Thanks to both of you, Im at school now but ill try it later tonight. Ill post the results here.

EDIT: It worked perfectly, thanks again.

Thanks,
Linus

[edited by - linus78 on April 29, 2002 1:27:56 PM]

This topic is closed to new replies.

Advertisement