Results 1 to 2 of 2

Math Help - Pivoting a 3D line with gyroscope data

  1. #1
    Newbie
    Joined
    Oct 2013
    From
    Houston TX USA
    Posts
    1

    Pivoting a 3D line with gyroscope data

    Hello. This is my first post here.
    For one of my applications, I need help figuring out how to manipulate few equations that I have to graph and pivot a single 3D line (using an electronic sketchbook called Processing). Here the syntax of the line:


    line(x1, y1, z1, x2, y2, z2)

    The above expression is a Processing function that allows me to graph a line. Where:


    x1, y1 and z1 are float coordinates of the first point.
    x2, y2 and z2 are float coordinates of the second point.


    I am getting the xyz coordinate values from a real gyroscope that I can rotate freely.


    For the purpouses of my application, the first point of the line is fixed to the origin.
    For simplicity, let's make x2=x, y2=y, z2=z, thus, my line function is now:


    line(0, 0, 0, x, y, z)

    What I really need is to graph my line in a manner that can pivot in all possible position.
    Let's start mentioning the formula of the distance 'd' that I am using:


    d = sqrt(x*x + y*y + z*z)

    I want to clarify something very important here regarding how I am reading the x, y and z coordinates from the gyroscope.
    Each coordinate contains circular values between 0 to 360 degrees. In other words, if I pivot the gyro 360 laying on my table,
    the z coordinate will change from 0 to 360. Similarly for the other two axis.

    So far I can graph correctly the line but pivoting (or rotating) one axis at a time. I.e.


    For the axis z:


    x = d * cos(radians(z))
    y = d * sin(radians(z))


    For the axis y:


    z = d * cos(radians(y))
    x = d * sin(radians(y))


    For the axis x:


    y = d * cos(radians(x))
    z = d * sin(radians(x))


    So far so good. My problems start when I try to put them together:


    I have tried the following:


    y1 = leng * sin(radians(zin));
    x2 = leng * cos(radians(zin));
    x1 = leng * sin(radians(yin));
    z2 = leng * cos(radians(yin));
    z1 = leng * sin(radians(xin));
    y2 = leng * cos(radians(xin));


    x = (x2+x1);
    y = (y1+y2);
    z = (z1+z2);


    When I graph the above equations, the line looks like pivots correctly but a some positions the lenght starts to change or even becomes zero.


    Again, what I just need is to find a way to generate x, y and z that permits the line pivots freely (with the distance fixed of course).
    Thank you very much for any comment. Regards!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Joined
    Sep 2012
    From
    Australia
    Posts
    3,651
    Thanks
    602

    Re: Pivoting a 3D line with gyroscope data

    Hey Palliser.

    What you are describing is known as gimbal lock: take a look at this Wiki site:

    Gimbal lock - Wikipedia, the free encyclopedia

    To get around this you should do a rotation around an axis or use quaternions and quaternion interpolation (if you are dealing with multiple axes).
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. gaussian elimiation with out pivoting - help!!!
    Posted in the Advanced Math Topics Forum
    Replies: 4
    Last Post: November 25th 2012, 01:50 AM
  2. gaussian elimination -- pivoting
    Posted in the Advanced Algebra Forum
    Replies: 4
    Last Post: December 8th 2010, 01:05 PM
  3. pivoting
    Posted in the Math Software Forum
    Replies: 0
    Last Post: May 1st 2009, 03:46 AM
  4. Mechanics- A gyroscope question
    Posted in the Advanced Applied Math Forum
    Replies: 0
    Last Post: March 31st 2009, 05:43 AM
  5. Scaled Partial Pivoting
    Posted in the Advanced Algebra Forum
    Replies: 0
    Last Post: March 30th 2006, 05:35 PM

Search Tags


/mathhelpforum @mathhelpforum