Results 1 to 3 of 3

Math Help - Find Ellipse knowing 2 points, half-axises, rotation angle

  1. #1
    Newbie
    Joined
    Jun 2013
    From
    Poland
    Posts
    1

    Question Find Ellipse knowing 2 points, half-axises, rotation angle

    Hello,

    I am implementing a SVG renderer and I just found a very nasty trigonometry problem. I already wrote a lot of geometric code, but nothing gave me so many headaches like "elliptical arcs" which area feature of SVG =D

    Basically I receive as input 2 points which bellong to the ellipse, the rotation of the ellipse in relation to axis X, and the sizes of the half-axises of the ellipse.

    And I want to find the center of the ellipse. I know that there are 2 solutions to the problem, and I need both.

    There are images ilustrating the problem here:

    Path - Elliptical Curve
    and
    SVG Basics Tutorials - Elliptical Arcs with SVG

    Here is what I tried so far:

    I know the following information:

    X,Y -> this is a point which bellongs to the ellipse. I have this point, but I don't know which parameter t=t2 is at this point
    Xstart,Ystart -> Another point of the ellipse that I know, has parameter t=t1
    CX,CY -> This is what I want! The center of the ellipse!

    solve 4 equations and 4 unknown values (CX, CY, t1, t2)
    X,Y has t=t2 // Xstart,Ystart has t=t1
    CX := X - RX*Cos(t2)*Cos(XRotation) + RY*Sin(t2)*Sin(XRotation);
    CX := XStart - RX*Cos(t1)*Cos(XRotation) + RY*Sin(t1)*Sin(XRotation);
    CY := Y - RY*Sin(t2)*Cos(XRotation) - RX*Cos(t2)*Sin(XRotation);
    CY := YStart - RY*Sin(t1)*Cos(XRotation) - RX*Cos(t1)*Sin(XRotation);


    Substituting we get 2 equations and 2 unknown values (t1, t2)
    X - RX*Cos(t2)*Cos(XRotation) + RY*Sin(t2)*Sin(XRotation) = XStart - RX*Cos(t1)*Cos(XRotation) + RY*Sin(t1)*Sin(XRotation)
    Y - RY*Sin(t2)*Cos(XRotation) - RX*Cos(t2)*Sin(XRotation) = YStart - RY*Sin(t1)*Cos(XRotation) - RX*Cos(t1)*Sin(XRotation)


    Simplify:


    A = RX*Cos(XRotation)
    B = RY*Cos(XRotation)
    C = RY*Sin(XRotation)
    D = RX*Sin(XRotation)


    X - A*Cos(t2) + C*Sin(t2) = XStart - A*Cos(t1) + C*Sin(t1)
    Y - B*Sin(t2) - D*Cos(t2) = YStart - B*Sin(t1) - D*Cos(t1)


    Attempt to corner Sin(t1):


    X - A*Cos(t2) + C*Sin(t2) = XStart - A*sqrt(1-Sin(t1)^2) + C*Sin(t1)
    X - A*Cos(t2) + C*Sin(t2) - XStart - C*Sin(t1) = - A*sqrt(1-Sin^2(t1))
    Mega = X - A*Cos(t2) + C*Sin(t2) - XStart
    Mega^2 - 2*Mega*C*Sin(t1) + C^2*Sin^2(t1) = A^2*(1-Sin^2(t1))
    Mega^2 - A^2 - 2*Mega*C*Sin(t1) + (C^2+A^2)*Sin^2(t1) = 0


    Baskara!!!


    AB = (C^2+A^2)
    BB = -2*Mega*C
    CB = Mega^2


    DeltaB=BB^2-4*AB*CB
    Sin(t1)=(-BB+/-sqrt(DeltaB))/(2*AB)


    Now roll it back!


    X - A*Cos(t2) + C*Sin(t2) = XStart - A*sqrt(1-Sin(t1)^2) + C*Sin(t1)

    But at this point I am totally lost ... the fully expanded equation is *huge*! And I have no idea if I am getting anywhere...

    Does anyone know what I could do to solve this in a simpler way? Because the way that I am trying so far is really big and nasty....
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Joined
    Sep 2012
    From
    Australia
    Posts
    4,031
    Thanks
    742

    Re: Find Ellipse knowing 2 points, half-axises, rotation angle

    Hey sekelsenmat.

    Why don't you rotate the points so that the axis are aligned with y and z axes and use parameterized equations to get the solution?

    If you have a general ellipse at some custom CX,CY then an axis aligned parameterization would be:

    EX = CX + RX*cos(t)
    EY = CY + RY*sin(t)

    From here you need to find the values of t that give CX and CY and the values that do this will be t = 0 and t = pi/2.

    If the ellipse has been rotated, then you need to rotate it so that it is axis aligned. You can rotate something by the inverse of its angle quite easily with a standard rotation matrix (with -theta as your argument).

    Overall though, once you get it so that the rotation axis are aligned to Y and Z, then given your points for EX and EY for two points, you obtain values of RX and RY by picking a value of t that eliminates the RX RY terms to get CX and CY (like mentioned above).
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Super Member
    Joined
    Dec 2012
    From
    Athens, OH, USA
    Posts
    688
    Thanks
    281

    Re: Find Ellipse knowing 2 points, half-axises, rotation angle

    Hi,
    I think it's easier if you don't use parametric equations. The attachment indicates a solution using the "standard" equations for an ellipse. As you probably know, arbitrary values for the current point, (xEnd,yEnd), rx and ry can possibly have no solution. I don't know what SVG does in this case; I didn't look very hard to find what happens. However, your code should take this possibility into account. If you have trouble turning the discusssion into code, post your questions in this thread and I'll try to answer.

    Find Ellipse knowing 2 points, half-axises, rotation angle-mhfellipsesa.png

    Find Ellipse knowing 2 points, half-axises, rotation angle-mhfellipsesb.png
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. How to find rotation angle given output of cos?
    Posted in the Trigonometry Forum
    Replies: 1
    Last Post: September 9th 2012, 07:09 PM
  2. Replies: 3
    Last Post: May 29th 2011, 07:48 AM
  3. Replies: 2
    Last Post: March 17th 2011, 01:35 PM
  4. Find equation of curve, by rotation of ellipse ?
    Posted in the Pre-Calculus Forum
    Replies: 1
    Last Post: March 11th 2011, 12:15 AM
  5. Replies: 3
    Last Post: February 27th 2009, 08:52 AM

Search Tags


/mathhelpforum @mathhelpforum