Results 1 to 11 of 11

Math Help - Plotting the points of a Curve.... Need Help pls...

  1. #1
    Newbie
    Joined
    Jan 2009
    Posts
    10

    Plotting the points of a Curve.... Need Help pls...

    If you know the X,Y location values, on a 2D grid of point, A and B how can you work out the X,Y locations along the grid of a curve that ends in both point? So you can plot a curve from A -> B along a perfect ARC.

    Example 01:- http://www5.picturepush.com/photo/a/...mg/1296823.png
    Example 02:- http://www1.picturepush.com/photo/a/...mg/1296819.png


    I am not really a maths guy. I have just run into this problem and need a solution and have had to basicly re-learn maths from scratch. Trying to remeber from when I was at school.

    So I have NO idea if I am even on the right track or way off base.... or if my method to get the points on the arc are correct. So if you have another solution for this instead of fixing my math, i would also love to see your math.


    This is How I have been doing it so far...

    My Steps
    1) I have assumed a value called H. This is the X,Y Location point of the top of a isos triangle, whose base line makes up the line from A-B.

    2) I have "invented" a value for the degrees of the = angles that of the isos triangle. I figure by changing this angle I can make the arc more or less rounded.

    3) I use the ANGLE D and the Length of the LINE A - > B to find the height of H.

    4) Then using A,B and H. I can then plot the points of all the X,Y cords along the ARC.

    This is My method... and here is my lame math... that doesn't seam to work.

    Ok, working out the location of H from the angles D

    1) work out distance between A and B, let's call this Di1:

    Di1 = sqrt((Xb - Xa)^2 + (Yb - Ya)^2)

    2) work out midpoint of AB line, let's call this M

    (Xm , Ym) = ((Xb + Xa) / 2 , (Yb + Ya) / 2)

    3) work out gradient of line AB, let's call this g1

    g1 = (Yb - Ya) / (Xb - Xa)

    4) work out gradient of line perpendicular to AB, let's call this g2

    g2 = -1 / g1 (note: this value won't exist if g1 = 0, need a special case, see below)

    5) work out angle between line perpendicular to AB and horizontal, let's call this phi

    phi = atan(g2), if g2 exists (I.e. if g1 is not 0)
    = 90 degrees = Pi/2 radians, if g1 is 0


    6) get distance between midpoint (M) and H, let's call this D2

    Di2 = Di1 * tan(D) / 2

    7) get coordinates for C

    (Xc , Yc) = (Xm + Di2 * cos(phi), Ym + Di2 * sin(phi))


    note, you'll get a semi circle when D are 45 degrees.


    OKKKKKaaaayyyyyy

    Now how to get the points on the ARC itself....


    1) Work out the centrepoint of the arc (let's call this point C) - this is the point that is the same distance from points A,B and H.

    Xc = [(Yb - Yh)(Xa^2 + Ya^2) + (Yh - Ya)(Xb^2 + Yb^2) + (Ya - Yb)(Xh^2 + Yh^2)]
    -------------------------------------------------------------------------------
    2*[Xa*Yb + Xb*Yh + Xh*Ya - Ya*Xb - Yb*Xh - Yh*Xa]

    Yc = [(Xb - Xh)(Ya^2 + Xa^2) + (Xh - Xa)(Yb^2 + Xb^2) + (Xa - Xb)(Yh^2 + Xh^2)]
    -------------------------------------------------------------------------------
    2*[Ya*Xb + Yb*Xh + Yh*Xa - Xa*Yb - Xb*Yh - Xh*Ya]


    2) Work out the radius of the arc, this can be done by calculating the distance between C and A (or C and H, or C and B).

    r = sqrt((Xb- Xc)^2 + (Yb - Yc)^2)


    3) Work out the the start and finish angles around the arc. The easiest way to do this is using a function called ATAN2 if you are using C or something similar.

    Start angle = angle between horizontal and the line joining C and A = atan2(Yb - Yc, Xb - Xc)
    Finish angle = angle between horizontal and the line joining C and B = atan2(Ya - Yc, Xa - Xc)


    4) any angle between the start angle and finish angle will give you a point along the arc, so you can use code like the following pseudo code to generate these points:

    for each angle theta between the start angle and finish angle do the following
    calculate the x coordinate as Xp = Xc + r * cos(theta)
    calculate the y coordinate as Yp = Yc + r * sin(theta)
    output the point on the arc as (Xp,Yp)
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member
    earboth's Avatar
    Joined
    Jan 2006
    From
    Germany
    Posts
    5,807
    Thanks
    116
    Quote Originally Posted by anewhobby View Post
    If you know the X,Y location values, on a 2D grid of point, A and B how can you work out the X,Y locations along the grid of a curve that ends in both point? So you can plot a curve from A -> B along a perfect ARC.

    ...
    1. A and B are the endpoints of a chord. You can find an infinite number of circles passing through A and B. The smallest has a radius of r=\dfrac{|\overline{AB}|}{2}

    2. The equation of a circle with its center at C(x_C , y_C) is:

    (x-x_C)^2 + (y-y_C)^2 = r^2

    3. If you have three points of a circle you can calculate x_C,\ y_C\ and\ r using the equation of #2.

    4. If you know the equation of the circle you only have to plug in a x-value (or y-value) to calculate the missing coordinate. (r is a constant!)
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jan 2009
    Posts
    10
    Quote Originally Posted by earboth View Post
    1. A and B are the endpoints of a chord. You can find an infinite number of circles passing through A and B. The smallest has a radius of r=\dfrac{|\overline{AB}|}{2}

    2. The equation of a circle with its center at C(x_C , y_C) is:

    (x-x_C)^2 + (y-y_C)^2 = r^2

    3. If you have three points of a circle you can calculate x_C,\ y_C\ and\ r using the equation of #2.

    4. If you know the equation of the circle you only have to plug in a x-value (or y-value) to calculate the missing coordinate. (r is a constant!)
    Yea this is why i was trying to do the Triangle thing to give me a third point at the top of the arc. So you work out H... this gives you 3 points to work with.

    I am not exactly sure what you are driving at here.

    Could you please attempt to explain this agian in a bit more detail.

    Please remeber i am not a math student and this is the first time i have tried maths in like 15 years or somthing so I am very rusty and i only ever had a high school education in maths.

    Thanks in advance.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Super Member
    earboth's Avatar
    Joined
    Jan 2006
    From
    Germany
    Posts
    5,807
    Thanks
    116
    Quote Originally Posted by anewhobby View Post
    Yea this is why i was trying to do the Triangle thing to give me a third point at the top of the arc. So you work out H... this gives you 3 points to work with.

    I am not exactly sure what you are driving at here.

    Could you please attempt to explain this agian in a bit more detail.

    ...
    It would be much easier for me to show you what can be done if I can get some (realistic!) data from you.

    As you've mentioned before the form of the arc depends on point H. So where from did you get the coordinates of this point?

    According to the sketches you posted with your previous posts you are working on a computer-screen with 1280 x 800 pixels. That means you have to convert real numbers into integers too.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Super Member
    earboth's Avatar
    Joined
    Jan 2006
    From
    Germany
    Posts
    5,807
    Thanks
    116
    Quote Originally Posted by anewhobby View Post
    ...

    I am not exactly sure what you are driving at here.

    Could you please attempt to explain this agian in a bit more detail.

    ...
    According to my previous post I've chosen the points

    B(600 , 100)
    A(500 , 1200)
    H(400 , 600)

    These points are placed on a circle around C(k, h) which has a radius of r. The equation of such a circle is:

    (x-k)^2 + (y-h)^2 = r^2

    The coordinates of A, B and H must satisfy this equation. Plug in the coordinates into the equation and solve for k, h and r:

    \begin{array}{lcr}B: (600-k)^2 + (100-h)^2 &=&r^2 \\ A: (500-k)^2 + (1200-h)^2 &=&r^2 \\ H: (400-k)^2 + (600-h)^2 &=&r^2 \end{array} ........ Expand the brackets:

    \begin{array}{lcr}B: 360000 - 1200k +k^2 + 10000 - 200h +h^2 &=&r^2 \\ A: 250000 - 1000k + k^2 + 1440000 - 288h +h^2 &=&r^2 \\ H: 160000 - 800k + k^2 + 360000 - 1200h + h^2 &=&r^2 \end{array} ........ Calculate B - A and B - H:

    \begin{array}{lcr}B-A:110000-200k-1430000+88h=0 \\ B-H:200000 - 400k -350000+1000h = 0\end{array}

    You are now dealing with a system of 2 simultaneous equations. I don't know which method you prefer to solve such a system. I've got:

    h = 732.3529411 ∧ k = 1455.882352 ∧ r = 1064.145123

    Since you have to use integer numbers (I assume!) the center could be at C(1456, 732 ) and r≤ = 1,132,405. As you may have noticed the center is outside the screen!

    The equation of the circle becomes:

    (x-1456)^2 + (y-732)^2 = 1,132,405

    To calculate the coordinates of points which belong to the arc you only have to plug in x- or y-values. (I would rather prefer to use y-values with your question)

    For instance: P(p, 900):

    (p-1456)^2 + (900-732)^2 = 1,132,405

    p^2-2912p + 309136 + 1015755 = 0 this is a quadratic equation. Use the quadratic formula to solve it:

    p\approx 2506.8~\vee~x\approx 405.2

    The first solution belongs to the lower part of the circle so we use P(405, 900)

    I ask you a favour: Please check my arithmetic. Probably I have made a silly mistake ...
    Attached Thumbnails Attached Thumbnails Plotting the points of a Curve.... Need Help pls...-bogen_aus3pkt.png  
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Jan 2009
    Posts
    10
    intertesting... I havn't had a chance to chekc your math... but I can nto see how you find out the value if H... you seamed to just define it at the start?
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Jan 2009
    Posts
    10
    Quote Originally Posted by earboth View Post
    According to my previous post I've chosen the points

    B(600 , 100)
    A(500 , 1200)
    H(400 , 600)

    These points are placed on a circle around C(k, h) which has a radius of r. The equation of such a circle is
    Where are you getting this K value from? We haver A,B,H and D as known values... but I am not sure what this K is or how you get it....

    um... yea.. well I do not understand much of what you did unfortunatly
    Follow Math Help Forum on Facebook and Google+

  8. #8
    MHF Contributor

    Joined
    Apr 2005
    Posts
    14,973
    Thanks
    1121
    Quote Originally Posted by anewhobby View Post
    intertesting... I havn't had a chance to chekc your math... but I can nto see how you find out the value if H... you seamed to just define it at the start?
    Yes, you were told in the very first response that there are an infinite number of different circular arcs passing through two given points. Earboth chose a value for H in order to have 3 points so there would be one solution.
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Newbie
    Joined
    Jan 2009
    Posts
    10
    Quote Originally Posted by HallsofIvy View Post
    Yes, you were told in the very first response that there are an infinite number of different circular arcs passing through two given points. Earboth chose a value for H in order to have 3 points so there would be one solution.
    Yes and like i said in the 1st post yo know the value of H as you have teh vlaes of "D", U use tehse to make a isos triangle ... with teh cord from A-B as teh base.... . .
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Super Member
    earboth's Avatar
    Joined
    Jan 2006
    From
    Germany
    Posts
    5,807
    Thanks
    116
    Quote Originally Posted by anewhobby View Post
    If you know the X,Y location values, on a 2D grid of point, A and B how can you work out the X,Y locations along the grid of a curve that ends in both point? So you can plot a curve from A -> B along a perfect ARC.

    ...
    My Steps
    1) I have assumed a value called H. This is the X,Y Location point of the top of a isos triangle, whose base line makes up the line from A-B.

    2) I have "invented" a value for the degrees of the = angles that of the isos triangle. I figure by changing this angle I can make the arc more or less rounded.

    ...
    Yes and like i said in the 1st post yo know the value of H as you have teh vlaes of "D", U use tehse to make a isos triangle ... with teh cord from A-B as teh base.... . .
    I did exactly the same as you did: I assumed and I invented ...

    But what I'm interested in is: Where did you get these values from? And how? And why?
    Follow Math Help Forum on Facebook and Google+

  11. #11
    Newbie
    Joined
    Jan 2009
    Posts
    10
    Quote Originally Posted by earboth View Post
    But what I'm interested in is: Where did you get these values from? And how? And why?
    I am using these maths to plot a curve between two points on a 2Dx,y grid. I am using it in a homemade computer game I am writting in my sapre time. The idea is that a player, who can be on any x,y location can "thorw" somthing at any other x,y location.

    So I have the two x,y locations as known values, Ax,Ay and Bx, By. I "assume" the value D. By increasing this value of D will create the arc of teh curve to be more rounded. Once it hits 45 it will be a perfect circle with the cord from A-B becoming the diameter.

    Everything is now workign i really apreciate your help guys.... It works out like this... ... ...

    Math to work out H
     Hx = (cos(-D) * (Bx - Ax) - sin(-D) * (By - Ay)) / (2 * cos(D)) + Ax
    Hy = (sin(-D) * (Bx - Ax) + cos(-D) * (By - Ay)) / (2 * cos(D)) + Ay

    Math to work out C
    Math and Explination found at Dr Math - Finding the Center of a Circle from Three Points @ Dr Math

    Math to work out any point along teh arc connecting A and B and H and using C as teh center point of circle

    - Work out the radius of arc
    r = sqrt((Xa - Xc)^2 + (Ya - Yc)^2)

    - Work out teh start and finish angles (deg on arc of start point and end point

    Start angle = angle between horizontal and the line joining C and A = atan2(Ya - Yc, Xa - Xc)
    Finish angle = angle between horizontal and the line joining C and B = atan2(Yb - Yc, Xb - Xc)

    any angle between the start angle and finish angle will give you a point along the arc, so you can use code like the following pseudo code to generate these points:

    for each angle theta between the start angle and finish angle do the following
    calculate the x coordinate as Xp = Xc + r * cos(theta)
    calculate the y coordinate as Yp = Yc + r * sin(theta)
    output the point on the arc as (Xp,Yp)
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 3
    Last Post: August 24th 2011, 11:35 AM
  2. Plotting a fitted curve in R
    Posted in the Math Software Forum
    Replies: 0
    Last Post: September 16th 2009, 01:59 AM
  3. Software for plotting moving points
    Posted in the Geometry Forum
    Replies: 0
    Last Post: September 10th 2009, 07:13 AM
  4. help with plotting curve
    Posted in the Advanced Math Topics Forum
    Replies: 2
    Last Post: June 12th 2009, 04:27 AM
  5. Help Please With Plotting Points..asap!!!!!!
    Posted in the Pre-Calculus Forum
    Replies: 3
    Last Post: March 30th 2008, 09:44 PM

Search Tags


/mathhelpforum @mathhelpforum