use trig mate
or send me your points and i will give you angle ok
or tell me what size you want your hole and with what tool you are using and i will give you code
hello
i am sorry.i have a question about calculate angle part of circle.I have center points and two point in circle.i need to angle between strart point and end point. i search internet but i did not find any formol.so i think may be you know this. so i want to help me please.
use trig mate
or send me your points and i will give you angle ok
or tell me what size you want your hole and with what tool you are using and i will give you code
First you have to find your radius. You can use any of the two point on the circle.
R=sqrt[(x-h)*(x-h)+(y-k)*(y-k)]
where:
R=radius
x=x coordinate of a point on the circle
y=y coordinate of the same point on the circle
h=x coordinate of the center
k=y coordinate of the center
sqrt=square root
then you have to find the chord length(the lenght of the line that join the 2 point on the circle)
L=sqrt[(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)]
where:
x1=x coordinate of the first point
x2=x coordinate of the second point
y1=y coordinate of the first point
y2=y coordinate of the second point
then you can calculate angle between two point
A=2*arcsin[L/(2*R)
What do these things have to do with G02?
G02 is a basic function and it should work on all machines without any problem.
I could not understand his basic problem.
Thankyou very much
i use this formol but i could not success.because i want to draw a circle with small lines.i mean i start a point and find secend point with increase degree and
draw a line between them and continue it so simulate a circle.
i write it in delphi.
a part of my program is;
Xs and Ys is start point and Xe and Ye is end point and I1 and J1 are cordinate of center
alpha:=Pi/180 //1 radian
L:=SQRT(((Xs-Xe)*(Xs-Xe))+((Ys-Ye)*(Ys-Ye)));
R1 := SQRT((Xe-I1)*(Xe-I1) + (Ye-J1)*(Ye-J1));
n:=L/(2*R1);
A:=2*arcsin(n);
X:=I1+R1*cos(alpha);
Y:=J1+R1*sin(alpha);
Paintbox1.Canvas.MoveTo(Round(X*Scale+OffX), Round(X*Scale+OffY)); // move to start point
while (alpha<A) do
begin
alpha:=alpha+Pi/180; //increase radian
X:=I1+R1*cos(alpha);
Y:=J1+R1*sin(alpha);
Paintbox1.Canvas.LineTo(Round(X*Scale+OffX), Round(X*Scale+OffY)); // draw a line
end;
please help me.....
Paintbox1.Canvas.MoveTo(Round(X*Scale+OffX), Round(X*Scale+OffY)); // move to start point
Paintbox1.Canvas.LineTo(Round(X*Scale+OffX), Round(X*Scale+OffY)); // draw a line
If your program is written like that, you use X coordinate instead of Y in both line
You forgot one important thing, you have to calculate alpha at start point. your arc could began somewhere else than 0 rad or deg.
To know your Alpha at start :Arcsin[(Y-J)/R] But arcsin is expressed between 90 and -90 deg (pi/2 -pi/2 rad)
so calculate Arccos[(X-I)/R] But arccos is expresse beween 0 and 180 deg.
suppose that
A1=arccos[(x-i)/R]
A2=arcsin[(y-J)/R]
if A1 and A2 are positive Alpha at start point=A1
if A1 is positive and A2 negative Alpha at start point=2pi-A1
if A1 is negative and A2 is positive Alpha at start point=A1
if A1 and A2 are negative Alpha at start point =2Pi-A1
Also, G02 is clockwise arc and the positive direction of the trigonometric circle is counterclockwise. Cause you add a positive value at each segment, you will turn counter clockwise(G03).
Why you dont move at Xs Ys to begin your arc. (you calculate the point after the start point and then start there)
When you calculate angle between start and end point with the formula i gave to you, you obtain a result between 0 and 180 deg (0 and pi rad) because L is always positive(it is the result of a square root)and R also is always positive, you have to determine if it is really the result of the formula or 2pi-(this result). Cause you have to see it from a clockwise point of view.
Use the same method to find aplha at end point that I suggest to find alpha at start point and you won't need the first formula i gave to you. With that you will get alpha at start point and alpha at end point both wit positive value from 0 to 2pi.
To find angle between start and end from a clockwise point of view:
If Alpha start>Alpha end Angle between =(Alpha at start)-(alpha at end)
If Alpha start< alpha end Angle between=2pi+[(Alpha at start)-(alpha at end)]
then it is easy enough to program wath you want I know nothing about delphi and you will have to do a couple of IF...Then or something like that to resolve these formula but once its done:
As=Alpha at start point(angle on the trigonometric circle of start point)
A=angle between start and End (from a clockwise point of view)
AI=angular increment between each segment
At=total increment
Xs=Xcoordinate at start point
Ys=y coordinate at start point
Xe=X coordinate at end point
Ye=ycoordinate at end point
I= x center
J= Y center
R= Radius
Paintbox1.Canvas.MoveTo(Round(Xs*Scale+OffX), Round(Ys*Scale+OffY)); // move to start point
At=AI
while (At<A) do
begin
As=As-At;
X:=I+1*cos(As);
Y:=J+R*sin(As);
Paintbox1.Canvas.LineTo(Round(X*Scale+OffX), Round(Y*Scale+OffY)); // draw a line
At=At+AI;
end;
Paintbox1.Canvas.LineTo(Round(Xe*Scale+OffX), Round(Ye*Scale+OffY)); // draw a line
Last edited by samu; 09-20-2010 at 01:57 PM.