Function to get X, Y position of an object orbiting a point, given a distance and angle in radians?

Posted by Jake Petroules on Stack Overflow See other posts from Stack Overflow or by Jake Petroules
Published on 2010-06-11T22:07:22Z Indexed on 2010/06/11 22:12 UTC
Read the original article Hit count: 223

Filed under:
|
|
|

I am trying to code a function for a camera that orbits a point. Assume a 3d coordinate plane where Z is up. Ignore Z.

Let's say the camera's position starts at (0, 0, z). The object to orbit is at, say (50, 50, z). So we have a distance of ~70 units. Calling the function with {(50, 50, z), 70, x} where x is the position in orbit, in radians, should return where the position of the camera should be.

I believe this involves cos and tan but my trig isn't that great...

point3d getCameraPosition(point3d objectPosition, float distance, float rotationRadians)
{
    // ???
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about math