Measuring the Angle Between Two Transforms for t Param of Quaternion.Slerp

So, I’m using Quaternion.Slerp to rotate a door hinge, but I’m having a hard time coming up with a good way to measure the t parameter.

I have a door. It has a knob. I have a start transform whose rotation corresponds to the closed rotation of the door and whose position corresponds to the approximate position of the knob when the door is closed. The same is true for my end transform, except for the door being open.

I’d like the door to be manually opened by the player moving their “hand” transform over the doorknob and pulling. From here, I thought I could use the dot product to measure the angle between the vector describing the start transform and the player hand transform.

Rad = cos^-1((A dot B) / (||A||*||B||))

or

float currentAngle = Mathf.Acos(Vector3.Dot(start.transform.position, tr.transform.position) / (start.position.magnitude * tr.position.magnitude)); float pull = (currentAngle * Mathf.Rad2Deg) / DegreesOfFreedom;

This isn’t working, the angles I’m getting are far too small, so either my math is wrong, or I’m approaching this the entirely wrong way.

I also realize that I’m not accounting for the fact that, for this process to really work, I need to measure the angle ONLY on the two axis that are not the axis of rotation for the door. I figured I could work on that as soon as I get this part figured out.

EDIT:

I’m waiting for someone else to fix error before I can test, but I think I’ve over complicated the entire problem.

float currentAngle = Vector3.Angle(start.transform.position, handPos);

The above code should work just as well.

Regarding zeroing the magnitude of the vector along the rotation axis, it be nice to have a way to present a vector as either a row or column vector (a matrix). It would make make doing the matrix math yourself easier.

Like Bonfire said, the problem was I was using the vectors of start and hand, instead of vectors ending at start and hand, and beginning at the rotation point. So it wasn’t the math, just my variables. Thanks for your help.