locked
body joint angles using kinect RRS feed

  • Question

  • hi,i have  just  working on kinect and c# programming so i am very amateur at it
    i liked to know  about joint angles

    i created this code just to test me skill without  using kinect 
    but em having trouble with this code 
    i supposed   vector3 v1 and vector3 v2 as a joint replacement 
    but the value return from  Find_angle   is 'nan'
    am i missing something in the process
    please any help in this regard will b helpful

    Vector3 V1 = new Vector3(100,40,90);

     Vector3 v2 = new Vector3(160,60,90);

    public MainWindow()
            {
                InitializeComponent();

                Vector3.Normalize(V1);
                Vector3.Normalize(v2);

                float Result = this.find_angle(V1,v2);
                MessageBox.Show(Result.ToString());

    }

     public float find_angle(Vector3 va, Vector3 vb)
            {
                float dot_pro=Vector3.Dot(va, vb);
                double angle = Math.Acos(dot_pro);

                angle = angle * 180 / Math.PI;

                return (float)(angle);
            }

     


    Wednesday, September 19, 2012 5:03 PM

All replies

  • I think you are passing the original values of V1 and V2 to Math.Acos. So you got NAN. (dot_pro must be >-1 and <1)

    Use:

    V1=Vector3.Normalize(V1);
    V2=Vector3.Normalize(v2);

    or just

    V1.Normalize();

    V2.Normalize();

    I hope it helps you.

    ____________________________________________________

    http://ktoi.site90.com/

    • Edited by BehnamGF Wednesday, September 19, 2012 7:27 PM
    • Proposed as answer by BehnamGF Friday, October 26, 2012 5:05 PM
    Wednesday, September 19, 2012 7:26 PM
  • Thank you for the help ....   now i know what unit vector  is and Acos was not returning any value 
    Thursday, September 20, 2012 6:46 PM