Function to rotate on a 3D sphere at a fixed distance?

832 Views Asked by At

Is there a single function or a set of functions that takes two points in 3d space, calculates the distance, and rotates a given radians or degrees?
[example: a plane flies around the equator of a planet, while the planet wobbles relative to the solar system. looking at point the plane is at, using the x,y,z of the solar system. using the center of the planet as (0, 0, 0)]

I have found the function for converting degrees to radians and getting square root for the distance:

import math  
math.radians(1)

math.sqrt(x)

example:

point_1 = [0, 0, 0]
point_2 = [4, 4, 4]

rotation about point_1, rotation 180 degrees or 1 radian would give

point_3 = [-4, -4, -4]
distance = sqtr( ((0-4)(0-4)) + ((0-4)(0-4)) + ((0-4)*(0-4)) )

If Rodrigues' rotation formula can be used, then it needs 2 angles. I would prefer an already made function, but will make my own if I can figure the equation that is needed.

1

There are 1 best solutions below

0
On

thanks to Spektre for pointing me in the right direction.

rho which is distance, is fixed. theta and phi are angles, 90 degrees to each other, so of course the angle that does not move is also fixed.

convert from Cartesian to spherical coordinates, move rotate one angle or both, then convert spherical back to Cartesian coordinates