Need help with tricky vector math. Limit magnitude of vector only in direction tangent to sphere.

20 Views Asked by At

I need helping figuring out some vector math for a project I am working on. Any help would be greatly appreciated.

Image a point like object, P, orbiting a sphere planet. P has a velocity vector associated with it that is manipulated by gravity and external acceleration. I want to limit the velocity of the object tangentially to the sphere, while preserving the velocity of the object in the direction toward the center of the sphere (gravity).

Variables:

 A normal 3D vector (vector from center of planet to point): *N*
 A velocity 3D vector: *V*
 A point 3D (origin of velocity vector): *P*
 A point 3D (origin planet): (0, 0, 0)

Goal: Limit the magnitude of V to some value x but only in the direction tangent to the sphere planet.

Thank you for your help I just cannot figure this out.