+ Reply to Thread
Results 1 to 11 of 11

Thread: Calculate an angle between 2 3D vectors?

  1. #1
    Registered User
    Join Date
    11-13-2008
    Location
    Colorado
    Posts
    55

    Calculate an angle between 2 3D vectors?

    So I have x, y, z coordinates in mm taken at a specific frame rate. I want the hip angle...which would be the angle between the shoulder, hip, and knee joint coordinates. But for the life of me I can't remember the function to calculate the angle! I attached an example of some data. I will have coordinates recording at 100 Hz for 2-3 seconds in the real data. Thanks in advanced.
    Attached Files Attached Files
    Last edited by gannon_w; 11-20-2011 at 08:19 PM.

  2. #2
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,764

    Re: Calculate an angle between 2 3D vectors?

    The dot product of the unit vectors is the cosine of the angle, so

    =DEGREES(ACOS(SUMPRODUCT(B6:D6, E6:G6) / SQRT(SUMSQ(B6:D6)) / SQRT(SUMSQ(E6:G6))))

    ... is the angle between shoulder and hip in frame 1
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    11-13-2008
    Location
    Colorado
    Posts
    55

    Re: Calculate an angle between 2 3D vectors?

    Isn't that just the angle of the trunk vector (hip to shoulder)? That would produce the absolute trunk angle...but what about the total hip joint angle (standing it is approx 180 deg while sitting up strait is approx 90 deg) taking into account the thigh which is from the hip to the knee? Would I add (H6:J6) to the sumproduct statement and add a "/SQRT(SUMSQ(H6:J6)"?

    Thanks again!

  4. #4
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,764

    Re: Calculate an angle between 2 3D vectors?

    I don't understand that question.

    You can't just add chained angles (think about it); but you can compute the angle between any two vectors using the formula with appropriate range references.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    11-13-2008
    Location
    Colorado
    Posts
    55

    Re: Calculate an angle between 2 3D vectors?

    Never heard of a chained angle? Let me reword to make sure I'm explaining correctly. Does that formula produce the angle between the two vectors from the xyz coordinates of the shoulder, to the xyz coordinates of the hip (origin of the angle) (vector 1), and to the xyz coordinates of the knee (vector 2). I don't see in the formula references to the knee coordinates (H6:J6).

    So vector 1 is the trunk and vector 2 is the thigh. The hip joint angle is the angle between the trunk segment and thigh segment. Is this more clear?

  6. #6
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,764

    Re: Calculate an angle between 2 3D vectors?

    1. You can add signed chained angles in 2D coordinates (10° + 3° = 13°, 10° - 3° = 7°), but the arc cosine of the dot product returns the unsigned acute angle between two vectors.

    2. You can't add chained angles in 3D at all. The angle between {1,0,0} and {0,1,0} is 90°, the angle between {0,1,0} and {0,0,1} is 90°, but the angle between {1,0,0} and {0,0,1} is not 180°.

    So I still don't understand the end objective.
    Last edited by shg; 11-20-2011 at 07:35 PM.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Registered User
    Join Date
    11-13-2008
    Location
    Colorado
    Posts
    55

    Re: Calculate an angle between 2 3D vectors?

    Hmmm, I'm not sure how else to explain it. Let me try again and please don't take offense if it seems simplistic.

    A joint angle like any angle has 3 points. The hip joint angle is drawn from shoulder to hip to knee. Imagine videoing someone and drawing the angle on the screen. If you lift your leg this angle will decrease. Let's say to 90 deg. Each of the three points will have a xyz coordinate...but if you flex your hip to an angle of 90 degrees, then if you rotate on your standing foot while maintaining the hip at 90 deg you will change the xyz coordinates of each point BUT the hip angle is still 90 deg. They will have rotated out of the plane of the tv screen...but it is still 90 degrees.

    What I have are xyz coordinates of a person's joints with respect to a world (environment like a room) origin they can move in. So if I flex to 90 deg, then take a few steps and turn a bit and flex my hip to 90 deg...the hip joint is still the same but the xyz coordinates of each point have changed.

    Does this help or should I just mark the thread as solved and calculate the 2D angle (which is easy but has error).

  8. #8
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,764

    Re: Calculate an angle between 2 3D vectors?

    I think I've misunderstood your data. I took them each as a vector, but now I think they are 3D positions taken from a tracker.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,764

    Re: Calculate an angle between 2 3D vectors?

    See attached.
    Attached Files Attached Files
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Registered User
    Join Date
    11-13-2008
    Location
    Colorado
    Posts
    55

    Re: Calculate an angle between 2 3D vectors?

    That is beautiful...and exactly what I want. Sorry for my confusing explanation. Yes I run a motion lab and until I can get a specific piece of software to calculate the angles from models I develope I have to use excel...but my math in that area is rusty.

    THANKS AGAIN!!!!!!

    Oyeah...Go Lufkin Panthers Football!
    Last edited by gannon_w; 11-20-2011 at 08:31 PM.

  11. #11
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,764

    Re: Calculate an angle between 2 3D vectors?

    You're welcome, good luck.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0