![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| G-Code Programing Discuss G-code programing and problems here! |
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
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. |
|
#3
| ||||
| ||||
| 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) |
|
#5
| |||
| |||
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..... |
| Sponsored Links |
|
#6
| |||
| |||
| you are right.but i want to write a program about Gcodes in delphi. i mean i need to write this for windows language and i had to a basic program for machine.i hope that you understand my mean. sorry my english is weak... |
|
#7
| ||||
| ||||
| 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 |
|
#8
| |||
| |||
| yes i write X insted of Y in this page.but i use Y in my program and i can not success.i can not find my mistake.i think everything is right and it is not error but it draw a extravagant lines that it is not like a circle.if you can please help me i don not have time.... |
|
#9
| ||||
| ||||
| 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 12:57 PM. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 5t problems | markjb | Fanuc | 16 | 11-30-2011 11:36 PM |
| 340 problems | cuthy83 | Daewoo/Doosan | 1 | 09-28-2009 06:44 PM |
| KMB-1 problems | MTMW | HURCO | 4 | 07-22-2007 03:40 AM |
| .dwg problems anyone??? | slideleft | BobCad-Cam | 10 | 03-23-2007 01:03 PM |
| Tap Problems | Skeeterd5150 | General Metal Working Machines | 33 | 06-07-2006 03:12 PM |