You already have 2 vectors:
N = (0,0,1) indicates directly from the origin.
P = (a, b, c) indicates from the origin to your point.
Calculate the unit vector at your point U = P / | P |
Calculate the unit vector perpendicular to U and N E = UXN
Calculate the unit vector perpendicular to U and E (this will touch the sphere) T = UXE T can point either north or south, so if Tz <0, multiply T by -1.
T now points north and is parallel to the plane tangent to the sphere at P.
Now you have enough information to build a rotation matrix (R), so you can rotate T around U. You can find how to make a matrix to rotate around any axis on wikipedia :
Using R, you can compute a vector indicating the direction of motion.
A = RT
A is the answer you are looking for.
Jeremy
source share