# Angles between two vectors in 3D space

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

## Recommended Posts

Please take a look at this picture I have two parts connected by a 'joint' in 3D space. Imagine part 1 is your right hand, part 2 is your right shoulder bone and the joint is your right shoulder socket. You can rotate your right hand freely in 3D space. I believe the two lines are related by two angles. What's the best and the fastest way to measure those two angles? If line 1 is moved to a new position in space, line 2 should also be moved accordingly, keeping those angles constant. How do I go about that?

##### Share on other sites
What does this:
Quote:
 I have two parts connected by a 'joint' in 3D space. Imagine part 1 is your right hand, part 2 is your right shoulder bone and the joint is your right shoulder socket. You can rotate your right hand freely in 3D space.

have to do with this:
Quote:
 believe the two lines are related by two angles.

And what two angles are you talking about?

Quote:
 If line 1 is moved to a new position in space, line 2 should also be moved accordingly, keeping those angles constant.How do I go about that?

Move line 2 with the same amount. But I'm quite sure that's not what you mean, are you trying to get line 2 out of line 1 with just an angle value?

##### Share on other sites
Stick figure of a person standing

This picture might make you understand better.

Initially, body part 1-4 is orthogonal to 1-2. If I change it to 180 degrees (raising your hand), the locations of 4-6 and 6-8 should also change, while preserving their current angles.

In a nutshell, if I move 1-4 to any position, the rest of the hand should follow accordingly

The same goes for the legs. If I raise the legs, the feet should follow suit.

##### Share on other sites
In order to achieve that you need a tree of transformations. What you'd get is something like this:

Shoulder     |Upper arm     |Lower arm     |    Hand    /  |Thumb  Index finger

First you transform the shoulder, then you multiply that transformation with the upper arm transformation, which should be relative to the shoulder, and then you take that transformation and multiply that with the lower arm transformation and this goes on till you reach the fingers. By rotating the shoulder now(or any other limb), all the other limbs that 'follow' will rotate as well and keep their position relative to the rotated limb.

##### Share on other sites
Thanks.
I have no problem with body part tree.

I'm just stuck in the transformation part. I have no clue how to measure the relative angle(s) between two body parts and how to transform the body parts to new locations while preserving their relative angle(s)

##### Share on other sites
Why would you want to measure the angle? Lets say you start out with a stretched out arm, every angle relative to their parent limb is 0 degrees(or 180 degrees, depends on how you look at it). If you rotate the the parent limb, all child limbs will still have an angle of 0 degrees relative to that parent. If you transform the way I described in my previous post that is.

##### Share on other sites
Well the pose in the picture is just an example. Actually the posture is arbitrary (sitting, standing, running.. etc). So you have to know the angles.

The hands may not necessarily be all stretched out 180'

##### Share on other sites
So what is it that you are trying to do? Are you trying to animate the body?

Yes

##### Share on other sites
Well you start out with an initial pose, all transformations being applied happen from this pose. Normally you would read the transformations from a file and what happens when you play a biceps curl animation is this(assuming initial pose shown on the left in your stick figure picture): the shoulder gets rotated over time by 90 degrees about the z- and x-axis(assuming the character faces in the z direction) and translated to the correct position. The transformation matrix used for the shoulder now gets multiplied by the transformation matrix of the upper arm which only consists of the initial translation matrix it had. The resulting matrix now gets used for the lower arm. First the lower arm gets rotated by 90 degrees about the x-axis and translated by the initial translation, this gives the transformation matrix for the lower arm relative to the upper arm. Multiplying the two matrices gives the transformation matrix that results in the lower arm getting up to the correct position with the right orientation.

So the relative angles between the limbs is always known, because you set them.

1. 1
2. 2
Rutin
22
3. 3
4. 4
frob
17
5. 5

• 9
• 33
• 13
• 12
• 10
• ### Forum Statistics

• Total Topics
632577
• Total Posts
3007157

×