I am using the Axis Angle technique on objects so that they are oriented away from a planet surface like in Super Mario Galaxy. I am using two unit vectors [0,1,0] and a normal vector from the planet. Is there any way to stop the 3D objects from spinning when they go near 180 degrees and still orient correctly? Could I use gimbal lock to fix it? This is what I have so far for my game in JavaScript:

`// Angles are in radians angle = Math.acos(dotProductVec3([0,1,0], forceNormal)); // Using two unit vectors to find the axis and angle if (angle > Math.PI / 2) { forceRotation.angle = Math.acos(dotProductVec3([0,-1,0], forceNormal)); forceRotation.axis = vec3Normalize(vec3CrossProduct([0,-1,0], forceNormal)); } else { forceRotation.angle = Math.acos(dotProductVec3([0,1,0], forceNormal)); forceRotation.axis = vec3Normalize(vec3CrossProduct([0,1,0], forceNormal)); } `

Above I am using a negative number on the y axis to stop the spin when 180 degrees has been reached. The problem is the objects point towards the planet rather than away. Also I have tried Quaternions but they seem to spin too.