# Unity Angle between Vectors, with a Twist

This topic is 4652 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

A month or so ago, I posted this thread about coading an inverse kinematics solver for my project: I've managed to code both a CCD and Jacobian solver, but I'm having some problems adding restrictions to the joint rotations. The way I'm dealing with restrictions is this : for every joint I have initialRotationVector = The default (or starting) rotation of the joint (and therefore bone): initial Rotation Vector in yellow (translated upwards from bone for view). actualRotationVector = The current rotation of the joint (and therefore bone): initial Rotation Vector in yellow, actual Rotation Vector in red. The joints only rotate along a single axis (so the joint connecting the leg to the body moves backwards and forwards (rotating on the Y axis)), whilst all the joints in the leg rotate along the X axis. Now for the Y axis joint, the angle between initial and actual rotation can be found easily using a Dot product. I can then check this against max and min angle limit for restricting the rotations (lets say from -30 degrees to +30 degrees). Because the joint is static (joining the leg to the body), its origin doesn't matter. For the X axis joints however, its not that simple. The initial rotation vector is affected by the rotation of the origin Y axis joint. In other words, in the second image the yellow vector should have rotated along with the leg, but maintained the original local height position of the bone. It is THAT angle that I need, the difference in height between both vectors. The problem is, I can't get the intial rotation vector to rotate along the Y axis, but maintain its height. I've tried all kinds of solutions, but I think I'm missing something. Can anyone help?

##### Share on other sites
Since no one's answered yet I'll go ahead and mention that I read your post over a couple of times, but couldn't quite figure out what you were asking. I can't comment on the IK stuff, but I'm assuming that the rotation of each bone is expressed in the local coordinate frame of its parent, no? In that case though restricting the x rotation of the lower leg joints should be trivial, so I must be missing something. Also, I'm not sure what you mean by the 'difference in height' between the vectors.

Anyway, if you still need help maybe you could provide a little more detail about the problem.

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 11
• 15
• 9
• 10
• 12
• ### Forum Statistics

• Total Topics
633004
• Total Posts
3009835
• ### Who's Online (See full list)

There are no registered users currently online

×