Hi,

I was starting to think along the same lines as you.
By the way do you have an A level or degree in maths or something?

I came up with the following.

If point1 coordinates are x1,y1
If point2 coordinates are x2,y2
If circle/arc centre coordinates are cx,cy then>>

cx=(x1+x2)/2
cy=(y1+y2)/2

Now for distances and angles>>

Angle1 is the angle to point1
Angle2 is the angle to point2

Angle1 is given by>>

Angle1=ArcSin( (y1-cy) / ( x1-cx) ) 'Opposite/ajacent

and Angle2 by>>

Angle2=ArcSin( (y2-cy) / ( x2-cx) ) 'Opposite/ajacent


I've been looking up code to do ArcSin ( or Inverse Sine ) function
on GOOGLE.

Anyway once i get the angle values and convert to RADIANS by dividing
the angles by the following number.>>
57.2957795 which is also equal to 360/(2*PI)

and the RADIUS=SQR( ((x1-cx)^2)) + ((y1-cy)^2) )

you can then say>>

SORRY THIS CODE IS FOR VB.NET
DOWNLOAD THE EXPRESS EDITION for FREE!!
( WHICH THIS CODE SHOULD WORK WITHIN ) HERE>>

http://msdn.microsoft.com/vstudio/express/vb/


        'cx and cy are the centre coordinates of the circle.        Dim cx As Integer        Dim cy As Integer        'x2 and y2 are the plotted positions that are calculated.        Dim x2 As Integer        Dim y2 As Integer        Dim Radius As Double        Dim PI As Double        'Just a loop Count variable to go plot each point        'on the arc or circle.        Dim Count As Double        'Set up a white PEN of width=1        Dim aPen As New Pen(Color.White, 1)        Radius = SQR( ((x1-cx)^2)) + ((y1-cy)^2) )        PI = Math.PI             For Count = Angle1 To Angle2 Step 0.05 'Can be any step value.            x2 = Math.Round(Radius * Math.Sin(Count) + cx, 3)            y2 = Math.Round(Radius * Math.Cos(Count) + cy, 3)           pictureBox1.CreateGraphics.DrawLine(aPen, x2, y2, x2 + 1, y2)        Next Count


I know this method is not "ideal" for some people as i'm not using
SetPixel, but to do that I believe you need to load a bitmap first.
With the above METHOD you can plot on the FORM itself.
To do this i think the last line needs to be changed within
the FOR NEXT loop to>>

Me.CreateGraphics.DrawLine(aPen, x2, y2, x2 + 1, y2)


To go backwards (anti-clockwise), put a minus sign in either equation in the code above so it reads as>>

x2 = Math.Round(-Radius * Math.Sin(Count) + cx, 3)
'or but not in both
y2 = Math.Round(-Radius * Math.Cos(Count) + cy, 3)

You could multiply the radius by minus 1.

I'm off to give it a try....


Regards,

Dr M.

P.S. Richard, i followed the bit about a right angled line for
all of the points to plot from but the arc from any other point, other than the centre, would be a partial ellipse, sometimes
a diagonal ellipse.

+ Recent posts