Results 1 to 4 of 4

Thread: Finding Start and End Points on an Arc Having the Bounding Rectangle and Angles

  1. #1
    Junior Member
    Join Date
    Jun 06
    Posts
    29

    Finding Start and End Points on an Arc Having the Bounding Rectangle and Angles

    I'm doing a program where I need to be able to find out exactly where the start and end points of an arc I draw are. I am drawing the arc using the Graphics object's conventions (with a bounding rectangle and a start and a sweep angle). It is easy enough to find the center of the ellipse with the information I have, but how do you find a point on an ellipse at a certain angle?

  2. #2
    Frenzied Member
    Join Date
    Oct 03
    Posts
    1,301

    Re: Finding Start and End Points on an Arc Having the Bounding Rectangle and Angles

    Do you need to use just a circle or noncircular ellipses too?

    What you could do is take the equation that describes the ellipse and the equation that desribes the line through the ellipse's center along the desired angle.
    Then you calculate where the line and ellipse intersect eachother, which will be in two points.
    You then determine which point is the one you want.

    An ellipse is described as (X^2/A^2) + (Y^2/B^2) = 1
    Where X and Y are the coordinates of a point on the ellipse relative to it's center, A is half the width and B is half the height of the ellipse.
    This with a horizontal major or minor axis.
    http://en.wikipedia.org/wiki/Ellipse

    A line, relative to the ellipse's center can be describes as Y = X * Tan(C)
    Were Where X and Y are the coordinates of a point on the line relative to the ellipse's center and C is the line's angle, 0° is up going clockwise.

    Solving the intersections of the ellipse and line will result in two points, where Xa = -Xb and Ya = -Yb.
    You can find the right point by testing if X and Sin(C) are on the same side of 0.
    If Sin(C) is 0, test Y and Cos(C).
    Last edited by jeroen79; Jun 9th, 2006 at 03:36 PM.

  3. #3
    Frenzied Member
    Join Date
    Oct 03
    Posts
    1,301

    Re: Finding Start and End Points on an Arc Having the Bounding Rectangle and Angles

    Try this:

    X = ( 1/( Tan(C)^2 + 1/A^2) )^0.5 * Sin(C)/Abs(Sin(C))
    Y = ( 1/(1/Tan(C)^2 + 1/B^2) )^0.5 * Cos(C)/Abs(Cos(C))

  4. #4
    Junior Member
    Join Date
    Jun 06
    Posts
    29

    Re: Finding Start and End Points on an Arc Having the Bounding Rectangle and Angles

    Oh wow, thanks for all the help.

    Someone I know was able to help me find an easier way without using a bunch of math:

    VB Code:
    1. Dim gp As New GraphicsPath()
    2. gp.AddArc(information)
    3. Dim firstPoint as PointF = gp.PathPoints(0)
    4. Dim secondPoint as PointF = gp.PathPoints(gp.PathPoints.Length - 1)

    But thanks for the help, I'm glad to know if I ever do this in another language I'll have some math done for it.

Posting Permissions

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