Coordinate conversions

I need to convert one coordinate type to another,

The first coordinate type has distance, angle to the right, and angle upwards. (We'll call these d,h, and v)
I need to convert these to the standard x,y,z Cartesian coordinates.

The original coordinates are relative to the origin so I don't need to worry about that (of course even if that were an issue, that is the easy part to solve.)
closed account (D80DSL3A)
Your coordinate system sounds similar to spherical polar, but with the 'angle upwards' (v?) measured off the xy plane rather than off the z axis. If the other angle 'to the right' (h?) is same as in spherical polar then:
projection of d onto xy plane = d*cos(v)
z = d*sin(v)
x = d*cos(v)*cos(h)
y = d*cos(v)*sin(h)

I hope I'm understanding your coordinate system correctly.

I'm sure you have your reasons for using the similar but unconventional coordinate system, but if you go with spherical polar you'll find a lot of resources for its' use.
Well, if I understand correctly, the azimuth is the angle to the right, but polar angle is measured from straight up, which makes no sense to me.

I developed these coordinates a while ago. They are for use from one object (like a ship) to another. So the angle to the right is how far towards starboard measured from the ship's orientation (the axis running from back to front), the angle upwards measures from the same, so in essence I can look up then over, or I can look over then up. Trying to do that with normal spherical coordinates is awkward because shifting from one angle to the next changes the origin I'm measuring from, which I find awkward to practically apply and use.

(star trek uses the same except origin axis is from ship to galactic center, this was where I originally got the idea, I just modded it so the ship's orientation was origin)

Thanks for this by the way, now to implement.
closed account (D80DSL3A)
You're welcome. It sounds like the polar angle 'to the right' has the opposite sense as in spherical polar (which is 'to the left' or to port).
This affects one equation above. Instead y = -d*cos(v)*sin(h), just a sign change.
I'm now picturing the x-axis as ahead, y-axis to port and z-axis overhead (straight up).
Cool thanks!

I almost forgot, are the angles measured in degrees or radians? (I haven't taken trig yet so I don't know which is normal.)
closed account (D80DSL3A)
The <cmath> library trig functions take an angle measured in radians.
Conveniently, the example code in the reference section here
http://www.cplusplus.com/reference/cmath/sin/
shows conversion from degrees to radians in the function call.
Cool, got everything to work. Thanks!
Topic archived. No new replies allowed.