# How to get angle difference between rotations for one axis?

I’m trying to find the orientation of an object per axis. The problem is that the quaternion behind the scenes is causing the euler to have unpredictable values spread across all axis.
So I’m trying to find the difference between an unrotated euler and the rotated euler, but I want to do it for each axis separately…
How would I be able to get the rotations for each axis?

Okay, well I implemented a function to do this… Let me know if there’s a simpler way.

``````function trueAxisAngle( axis, quaternion ){
let direction = new THREE.Vector3( 0,0,1 );
let origin = new THREE.Vector3( 0,0,1 );
if(axis=='z'){
direction.set( 1,0,0 );
origin.set( 1,0,0 );
}
direction.applyQuaternion( quaternion );

direction.x = ( axis=='x' ? 0 : direction.x );
direction.y = ( axis=='y' ? 0 : direction.y );
direction.z = ( axis=='z' ? 0 : direction.z );

direction.normalize();

let angle = origin.angleTo( direction );

if( axis == 'x' && direction.y > 0) angle = THREE.MathUtils.degToRad(360)-angle;
if( axis == 'y' && direction.x < 0) angle = THREE.MathUtils.degToRad(360)-angle;
if( axis == 'z' && direction.y < 0) angle = THREE.MathUtils.degToRad(360)-angle;

return angle;
}``````

hmm… well this isn’t accurate, because if the object is rotate in multiple axis, then the resulting angle is wrong…

1. My kindergarten maths may be wrong, but there aren’t any angles on axes (except maybe for 0 and 180 degrees) ? It’s a 1D line, and to measure an angle you’d need at least 2 axes that define some plane (or one that defines a plane normal.)

2. If you have two vectors in 3D, and would like to measure the angle difference between them on a specific plane (defined by axes, ex. XY, XZ, YZ) - you can project them on that plane, and then either calculate a dot product or just use .angleTo.

Thanks for clarifying that. I wasn’t sure how to explain it, but that makes sense.