Your question, your audience. Choose who sees your identity—and your question—with question security.

Hi experts

if i have two given end points (a, b) (c, d) of an arc then

is it possible to find the equation of the arc ?( i mean equation of the circle in which it belongs)

its urgent please...

Thanks

if i have two given end points (a, b) (c, d) of an arc then

is it possible to find the equation of the arc ?( i mean equation of the circle in which it belongs)

its urgent please...

Thanks

Is the arc a perfect semi-circle? I'm guessing not; in which case, I believe you need to specify the radius of the circle...

d = sqrt( (c-a)^2 + (d-b)^2 )

And therefore, to calcualte the circumference of the circle, you'd use:

c = PI(d)

Or the area of the circle:

a = PI (d/2)^2

thanks for the quick reply

Arc need not be semi circle in most of the case ..:-(

is it possible to get centre and radius, if any two points in an arc is given ?

If you can specify the ange of the arc, then this should work:

c (circumference of circle) = PI * 2( Sin( 180 - (theta)) ( sqrt( (c-a)^2 + (d-b)^2 ) / Sin(theta) )

I'll see if I can come up with one for three points though..

Regards;

ok is there a way to find the angle of a an arc, when two end points are given?

InteractiveMind , i only have two end points of an arc with me :-(

i am keeping this question open for getting more ideas ...

Do you see? The chords (which can be presented as a vector of the two points you have) are the same size, but can both fit perfectly onto two different sized circles.

In which case, you would need to either specify a third point, or the angle to which the arc spans.

Sorry.

Regards;

I'm confident that there's a way round this: btw, I program also, so I have a good idea of the concepts that you're working with here...

Assuming it's an application you're working on here, what does it do? Where do you get the two points for this arc from?

Question is updated :

consider u r given three points

(a, b) (p,q) (c,d)

where first and last are end points of the arc, and (p,q) a point in between end points

now is it possible to find centre or radius ?

A = arccos( ( Ux(Vx) + Uy(Vy) ) / |U| |V| )

theta = 360 - 2A

c (circumference of circle) = PI * 2( Sin( 180 - (theta)) ( sqrt( (c-a)^2 + (d-b)^2 ) / Sin(theta) )

where U and V are the two vectors (U = (a,b) to (c,d) & V = (c,d) to (e,f)). But it's not the nicest thing to work with :) lol

i have set of points in advance , i can join these points to make a line graph. but i need to make it smooth curve. Any idea ?

Okay.. this "smooth curve": is it just a single arc (curve), or will it be a load of combined arcs?

(a, b) (p,q) (c,d)

where first and last are end points of the arc, and (p,q) a point in between end points

now is it possible to find centre or radius ?

(dx1, dy1) = (p,q) - (a,b) // differences between the points

(dx2, dy2) = (p,q) - (c,d)

(cx1, cy1) = 0.5*((p,q) + (a,b)); // centerpoints between points

(cx2, cy2) = 0.5*((p,q) + (c,d));

// just to keep the expressions below simple

K1 = -dy1 * cx1 + dx1 * cy1;

K2 = -dy2 * cx2 + dx2 * cy2;

Here are the line equations for the bisectors of the lines between points.

-dy1 * x + dx1 * y = K1

-dy2 * x + dx2 * y = K2

These two lines intersect at the center of the circle. Using Kramer's rule:

Det = -dy1 *dx2 + dy2 * dx1; // when Determinant is 0, the three points are colinear and there is no solution

circlex = (K1 * dx2 - K2 * dx1) / Det;

circley = (-dy1 * K2 + dy2 * K1) / Det;

The circle is centered at (centerx, centery). Radius is sqrt((centerx - a)^2 + (centery - b)^2).

Hermite Splines (Cardinal variety)

Given points pk=(xk,uk) then a smooth curve can be defined between 2 points pk=(xk,yk) and pk+1 (xk+1,yk) by a parametric curve P(u)= (x(u),y(u)) 0<u<1 where

P(u) is a cubic between 2 points pk points pk+1 and with the derivatives defined as Dpk and Dpk+1 at either end

P(u)=pk(2u3-3u2+1) + pk+1(-2u3+3u2) + Dpk(u3-2u2+u) + Dpk+1(u3-u2)

and where

Dpk = 0.5(1 - t)(pk+1 - pk-1)

Dpk+1 = 0.5(1 - t)(pk+2 - pk)

t is a user defined constant and is the tension parameter. t=0 gives Catmull-Rom splines, t>0 gives a tighter curve, t<0 looser curve.

@NovaDenizen

>>circlex = (K1 * dx2 - K2 * dx1) / Det;

>>circley = (-dy1 * K2 + dy2 * K1) / Det;

u mean to say that these are the coordinates of the centre. ok then i will check it out.

@GwynforWeb

>>P(u)=pk(2u³-3u²+1) + pk+1(-2u³+3u²) + Dpk(u³-2u²+u) + Dpk+1(u³-u²)

sorry, its very difficult for me to understand ur statements, i am not a genius in maths

i only need formula to find centre of the arc, i only have is 3 points as i commented earlier.

using those values i need to calculate the centre or radius of the arc. thats all.

i will check it out NovaDenizen's comment,

anyway the question is open ....

;-)

Shiju

@InteractiveMind

>> this "smooth curve": is it just a single arc (curve), or will it be a load of combined arcs?

sorry i forgot to reply. yes it will be a load of combined arcs.

suppose there are 5 points then

then take points 1,2,3 and draw arc from 1 to 2.

now take points 2,3,4 and draw arc from 2 to 3.

now take points 3,4,5 and draw arc from 3 to 4.

now join 4 to 5.

;-)

Shiju

The ugly point is that the curve I constructed didn't pass over the given points, but over their mid points, so if you have point 1,2,3,4 and 5, then you also have mid points that you can call 1-2 (mid point betwen 1 and 2), 2-3, 3-4 and 4-5.

The idea behind it, if you would use it, is that: Duplicate first and last point, so you have points 0,1,2,3,4,5 and 6, now, for each "real" point (from 1 to 5), for instance point 3, you draw the arc that start on previous mid point (2-3), ends on following mid point (3-4), but the trick to avoid ugly joints is not force the arc to pass on the real point 3, instead, you make this:

From 2-3, "draw" a line perpendicular to vector that goes from (2-3) to 3, and from 3-4 draw another line perpendicular to vecto from (3-4) to 3. Those two lines intersect on the center of the arc to be drawed. Repeat it with all the "real" points, and you get a "Spline" line made up of circle arcs that joint perfectly smooth... but it doesn't pass throu the original points, remember!

If you need the curve to pass throu a set of given points, and the curve to be smooth, then you HAVE to go to a spline function. It is not that difficult, I can explain a little bit for you:

The idea is that given a "control point set", and a pair of consecutive points of that set, you can easily find a pair of functions X(t) and Y(t), with t from 0 to 1, that when drawed, you get a perfect smooth curve from one point to the other. You have to repeat it from pair 1 and 2, then pair 2 and 3, and so on to the last pair 4 and 5 in our case, constructing a single curve passing on all points and being perfectly smooth.

Hermite Spline is one of the possible formulas to use, there are others, but this one is simple (in comparation) and very smooth. Other options can be X(t) and Y(t) being single polinomials (in Hermite splines you have several X(t) and Y(t), not a single pair) of grade N-1 (N= number of points), but it has a big problem: The more points you use, the more "drastic" the curve is... it doesn't tend to be gentle and smooth, it tends more to be abrupt and to go away from your paper sheet... unusable!

So you better use Splines, beliebe me, you have not a simplier solution for that!

GwynforWeb has given you the formulas I mentioned before to build the X(t) and Y(t) that will joint to adjacent points, you need to code them, and draw each one of them on screen by using somthing like this:

//The main loop should look like this (delphi pseudo-code):

var Dpk, Dpk1: double;

CoordX, CoordY: double;

X, Y: array of double;

//N = Number of points

//X[k] an Y[k] = coordinates of point number k.

For k:= 1 to N-1 do begin

//For each segment

For t:= 0 to 1 step 0.01 do begin

Dpk:= 0.5*(1 - t)*(X[k+1] - X[k-1]);

Dpk1:= 0.5*(1 - t)*(X[k+2] -X[k]);

CoordX:= X[k]*(2*t^3 - 3*t^2+1) + X[k+1]*(-2*t^3+3*t^2) + X[k]*(t^3-2*t^2+t) + X[k+1]*(t^3-t^2);

CoordY:= Y[k]*(2*t^3 - 3*t^2+1) + Y[k+1]*(-2*t^3+3*t^2) + Y[k]*(t^3-2*t^2+t) + Y[k+1]*(t^3-t^2);

Draw_point_at( CoordX, CoordY);

end;

end;

As you see, it is not so complicated, really simplier than using arcs.

Of course you could make it better, for instance, precalculate t^2 and t^3 to speed up the calcs, and draw small lines between actual point and prior point instead of just plotting isolated points, etc, but the basic code is just as simple as this example.

A more polished version of the code using the 2 ideas mentioned avobe:

//The main loop should look like this (delphi pseudo-code):

var Dpk, Dpk1: double;

CoordX, CoordY, LastX, LastY, t2, t3: double;

X, Y: array of double;

//N = Number of points

//X[k] an Y[k] = coordinates of point number k.

For k:= 1 to N-1 do begin

//For each segment

For t:= 0 to 1 step 0.01 do begin

//Precalculate t^2 and t^3 to speed up a little...

t2:= t^2;

t3:= t2*t;

Dpk:= 0.5*(1 - t)*(X[k+1] - X[k-1]);

Dpk1:= 0.5*(1 - t)*(X[k+2] -X[k]);

CoordX:= X[k]*(2*t3 - 3*t2+1) + X[k+1]*(-2*t3+3*t^2) + X[k]*(t3-2*t2+t) + X[k+1]*(t3-t2);

CoordY:= Y[k]*(2*t3 - 3*t2+1) + Y[k+1]*(-2*t3+3*t^2) + Y[k]*(t3-2*t2+t) + Y[k+1]*(t3-t2);

//The first point is not drawed, we need 2 points to draw a segment

if NOT((k=1) and (t=0)) then

Draw_Line(LastX, LastY, CoordX, CoordY);

//Store this point to be used in next segment

LastX:= CoordX;

LastY:= CoordY;

end;

end;

CoordX:= X[k]*(2*t3 - 3*t2+1) + X[k+1]*(-2*t3+3*t^2) + Dpk*(t3-2*t2+t) + Dpk1*(t3-t2);

CoordY:= Y[k]*(2*t3 - 3*t2+1) + Y[k+1]*(-2*t3+3*t^2) + Dpk*(t3-2*t2+t) + Dpk1*(t3-t2);

You can do some algebra and get an exact solution. Personally I like to minimize risk of algebra errors by making up variable names for as many intermediate expressions as possible. Anyway here are the equations.

Suppose (x0, y0) is the unknown center of the circle that passes through your three points, (x1, y1), (x2, y2), (x3, y3), with unknown radius r. Solve for x0 in

Eq1 (x1 - x0)^2 + (y1 - y0)^2 = (x2 - x0)^2 + (y2 - y0)^2

(this is true because both sides are equal to the radius squared)

Plug the expression for x0 into

Eq2 (x1 - x0)^2 + (y1 - y0)^2 = (x3 - x0)^2 + (y3 - y0)^2

(again, this is true because both sides are equal to the radius squared)

Solve for y0. You now have an actual value for y0. Up to this point you've done some messy but straightforward algebra. The squares of x0 and y0 drop out, so you'll just be solving a pair of simultaneous equations. (Let me know if you have any trouble with this -- I'll have time to do it about 5 hours from now. We don't have to use my variable names -- we can use a, b, p, q, etc. if you prefer.)

Plug the value of y0 into Eq1 to calculate the value of x0. Calculate r with

Eq3 r = sqrt[ (x1 - x0)^2 + (y2 - y0)^2 ]

Now that you have values for x0, y0 and r, you can, for any desired value of x, calculate the upper hemisphere y-coordinate with

Eq4 y = y0 + sqrt[ r^2 - (x - x0)^2 ]

and the lower hemisphere y-coordinate with

Eq5 y = y0 - sqrt[ r^2 - (x-x0)^2 ]

Good luck!

mathbiol

then the circle fitting through the 3 points is

(x-h)² + (y-k)² = r²

where

k = ((a²+b²)(e-c) + (c²+d²)(a-e) + (e²+f²)(c-a)) / (2(b(e-c)+d(a-e)+f(c-a)))

h = ((a²+b²)(f-d) + (c²+d²)(b-f) + (e²+f²)(d-b)) / (2(a(f-d)+c(b-f)+e(d-b)))

r² = (a-h)² + (b-k)²

Gwyn did the algebra, and it came out elegantly, and easy to read with his choice of letters.

Just to make sure you know how to use his equations:

Calculate k and h as he wrote. Then calculate

r = sqrt[ (a-h)² + (b-k)² ]

Now if you have a value of x and would like to find the two corresponding y values (upper and lower hemispheres):

yupper = k + sqrt[ r² - (x-h)² ]

ylower = k - sqrt[ r² - (x-h)² ]

I’m sorry I did not notice earlier that NovaDenizen’s solution is equivalent to this approach – it is also exact.

mathbiol

@mathbiol

excellent , i got ur statements. very helpful way of teaching thank u

i tried ur solved equations u gave and finally reached GwynforWeb's result

@GwynforWeb

u gave me what i asked , thank u

but i think i need to go for somthing like Hermite Splines as u said

@Sergio_Hdez

Can u please make ur formula simple so that i can put values as GwynforWeb has given

Now another critical problem is, three points may not be in the circle always, it may be another curve. and i am really stuck here

ok see, A B and C are points in the Arc. where A and B are end points

my "aim is to convert a line graph into Curved graph"

and i only have is set of points.

;-)

Shiju

>>For k:= 1 to N-1 do begin

>> Dpk:= 0.5*(1 - t)*(X[k+1] - X[k-1]);

>> Dpk1:= 0.5*(1 - t)*(X[k+2] -X[k]);

can u please check it out.

if my array index starts from 0 to N-1, there may have problems

well, i tried ur code it works, but in each point there seems to be a slight jumping on sharp edges

is it possible to bend smoothly on edges ?

There are lots of numerical methods for lots of different problems. Can you tell us more about yours? You have three points, and you'd like to draw a smooth curve through them. You were originally thinking "circle", but now you're thinking that a circle might not be the best sort of curve for your problem.... Is this right? Can you tell us a bit more about what you will do with the curve once you've got it? Perhaps you'd like to display it on the screen as part of some sort of graphic. Perhaps you'd like to interpolate -- that means that you've got an x-coordinate value somewhere in between the endpoints, and you'd like to calculate a y-coordinate value that sits on the smooth curve that passes through your three points....

mathbiol

yes, u guessed it right

i have a set of co-ordinates and i can easily join points to make a line graph. but that doesnt solve my problem. i would like to join these points using a smooth curve. and i started thinking the following method (i mentioned it before)

suppose there are 5 points then

then take points 1,2,3 and draw curve from 1 to 2.

now take points 2,3,4 and draw curve from 2 to 3.

now take points 3,4,5 and draw curve from 3 to 4.

now join 4 to 5.

Not at all easy; I truly think that you should ask yourself if it's *really* worth all the bother... ?

Regards;

draw curve from 1 to 2, taking the points 1,1,2,3

draw curve from 2 to 3, taking the points 1,2,3,4

draw curve from 3 to 4, taking the points 2,3,4,5

draw curve from 4 to 5, taking the points 3,4,5,5

where the curve from b to c, taking the points a,b,c,d is

(1-t)*(t+1)*(b+(c-a)*t) + t*(2-t)*(c+(b-d)*(1-t))

where t goes from 0 to 1

(1-t)*b + t*c + t*(1-t)*((1-t)*(b-a) + t*(c-d))

or

(1-t)*b + t*c + t*(1-t)²*(b-a) + t²*(1-t)*(c-d)

@ozo

thank u for the comment. i am little bit confused

ok if i am drawing curve from 1 to 2, taking the points 1,1,2,3

for each x value from point 1 to point 2

i need to use this formula for getting y value like this

for point1_x_value to point2_x_value

for t = 0 to 1 step 0.01

y = (1-t)*b + t*c + t*(1-t)²*(b-a) + t²*(1-t)*(c-d)

drawpoint(x,y)

next

next

am i got correctl ?

I guess the circle solution didn't give you the shape you would like.... In that case (without knowing more about what your goals are), I would agree with GwynforWeb that you should go with splines. I will give you a basic idea of how they work. Splines are a fun project.

You can work with three or more points. The algorithm is the same, regardless of how many points you have. Let’s call them Pi = (xi, yi). I will assume that whatever points you decide to work with are exactly where you want them – in other words, you really do want the drawn curve to go exactly through your points Pi.

To explain the basic idea, I will assume you have three points. We would like to find a function f1(x) that gives us the curve from P1 to P2 and a function f2(x) that goes from P2 to P3. We want f1 and f2 to be continuous at P2, in other words f1(x2) and f2(x2) should both equal y2. In addition we want all the derivatives at P2 to match up with each other, so that the two curve segments blend together as smoothly as possible.

Let’s choose a nice, easy form of the functions fi – let’s make them polynomials. A quadratic would restrict the shape of the curve segments too much. So let’s use cubics: fi(x) = ai x³ + bi x² + ci x + di. We know the value of f1 at P1 and f2 at P2, so:

Eq1 a1 x1³ + b1 x1² + c1 x1 + d1 = y1

Eq2 a2 x3³ + b2 x3² + c2 x3 + d2 = y3

The continuity at P2 gives us

Eq3 a1 x2³ + b1 x2² + c1 x2 + d1 = y2

Eq4 a2 x2³ + b2 x2² + c2 x2 + d2 = y2

Now we need to differentiate fi(x) with respect to x. The first derivative is

fiprime(x) = 3 ai x² + 2 bi x + ci

We want f1prime evaluated at x2 to be equal to f2prime evaluated at x2:

Eq5 3 a1 x2² + 2 b1 x2 + c1 - 3 a2 x2² - 2 b2 x2 – c2 = 0

Do the same thing using the second derivative:

Eq6 6 a1 x2 + 2 b1 - 6 a2 x2 - 2 b2 = 0

Now we turn the reversible jacket inside out to show the lining. Notice that we actually know the values of the xi, but we would like to find the values of the ai. So change your point of view and think of the ai as the variables and the xi as the coefficients. This is easier to do if you rewrite the equations. I’ll show you Eq1 rewritten as an example:

Eq1 x1³ a1 + x1² b1 + x1 c1 + d1 = y1

Okay, we’ve got six linear equations in eight unknowns. If we had two more equations, we’d be able to solve for the ai!

No matter how many points you start out with, you’ll always get to this same situation, of being just two equations short of a solution.

GwynforWeb suggested using the Hermite approach, in which you specify the derivatives at the endpoints. The natural cubic spline approach has you setting the second derivatives to zero at the endpoints. They’re both reasonable ways of coming up with two more equations. Or there may be something special about your situation that allows you to specify something else about the endpoints.

There are routines and numerical recipes that solve the linear system for you, or you can write your own.

The more you tell us about the problem you started with, the easier it is for us to express opinions about appropriate endpoint assumptions and number of points to use.

mathbiol

P.S. Does anyone know how to get subscripts to come out in a posting?

@ozo

Thank u ozo, i tried ur method. it worked, it draws smooth curves.

But if absolute value of difference between two adjacent y-coordinates are high then instead of bending, it takes a sharp bending(at palce between both the points) like 'V' shape

but it works fine otherwise . any idea ?

in such case i need either a straight line or a purely bend curve.

i hope i have expressed my problem clearly. thank u

@Sergio_Hdez

i tried ur code and worked, and got a similar problem of sharp edge bending.

But if absolute value of difference between two adjacent y-coordinates are high, i get a straight line, and its ok for that case, but in the opposite case i get smooth curve ONLY if y coordinate differences are less

@mathbiol

thank u , ur comments are very explanative.

just like a teacher's advice

i have read ur statements , and stuck with the following statements

>>If we had two more equations, we’d be able to solve for the ai!

that means we couldnt follow the method ??

Here's what I meant:

If you have a system of eight linear equations in eight unknowns, then you can solve for the unknowns. I derived six spline equations. So we need two more in order to find a solution.

There are at least two reasonable ways to come up with two more equations for your problem. You could use the Hermite approach or the natural spline approach.

Both will give you a smooth result no matter what your initial points are.

mathbiol

P.S. Do all my apostrophes come out as

’

on other people's computers? (I use an international English keyboard so as to be able to type easily in other languages.)

I think the Bezier curves are a subset of the Hermite curves that mathbiol has introduced, or is it the other way around?

Paul

the shape of the cubic spline I gave should be the same as the shape of the curve when absolute value of difference between two adjacent y-coordinates are low, just stretched

what are

point0_y_value, point1_y_value, point2_y_value, point3_y_value

when you see a sharp bend?

i think Bezier curves dont meet all endpoints we specify it. i am looking for hermite

@ozo

see if my 6 points are like this

line segment from a to b has a sharp bending at the middle of the line ab

this is the case with bc, cd , de and ef

bending is like this

/

/

\

\

b* d* f*

a* c* e*

0

0.109

0.232

0.363

0.496

0.625

0.744

0.847

0.928

0.981

1

0.972

0.896

0.784

0.648

0.5

0.352

0.216

0.104

0.028

0

0.028

0.104

0.216

0.352

0.5

0.648

0.784

0.896

0.972

1

0.972

0.896

0.784

0.648

0.5

0.352

0.216

0.104

0.028

0

0.019

0.072

0.153

0.256

0.375

0.504

0.637

0.768

0.891

1

I see no sharp bend there.

Thank you for showing us what your points are like. GwynforWeb suggested you use a spline fit. We can now choose which type of spline is best for your points.

Let's use ozo's values as an example:

(x,y)

P1 = (0,0) (you called this a)

P2 = (1,1) (you called this b)

P3 = (2,0)

P4 = (3,1)

P5 = (4,0)

P6 = (5,1)

Now we're cooking! Your spline should be periodic! In other words, we would like the curve to look the same between P3 and P4 as it does between P1 and P2. So we will use three points, exactly as I derived the six equations in the earlier comment, plus two new constraints:

(1) the curve should have the same slope at P1 and P3

(2) the curve should have the same second derivative at P1 and P3

From (1) we get

Eq 7 3 a1 x1² + 2 b1 x1 + c1 - 3 a2 x3² - 2 b2 x3 – c2 = 0

From (2) we get

Eq 8 6 a1 x1 + 2 b1 - 6 a2 x3 - 2 b2 = 0

Now we can solve for the unknowns ai and use the resulting polynomial functions to plot your curve.

You can either use these derivations to make your own code, or use one of many spline packages, with periodic endpoint conditions.

mathbiol

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

for t = 0 to 1 step 0.01

y = (1-t)*point1_y_value + t*point2_y_value + t*(1-t)²*(point1_y_value-p

x = (1-t)*point1_x_value + t*point2_x_value + t*(1-t)²*(point1_x_value-p

drawpoint(x,y)

next