|
Post by nsbrown on Sept 4, 2022 5:39:08 GMT -5
Hi all, I need to draw a part of a circle in my program. Is there a graphical way to define a circle to be say 60 degrees? Or does anyone have an idea how to draw part of a circle using a loop of lines?
tnx, Sharon
|
|
|
Post by Walt Decker on Sept 4, 2022 8:38:22 GMT -5
Rad = 4 * ATN(1) / 180 Radius = 25 Cx = 50 Cy = 50 X1 = Cx Y1 = Cy - Radius X = 0 Y = 0 NumDegrees = 60
PRINT #WIN.GFX, "PLACE ";X1;" ";Y1 PRINT #WIN.GFX, "DOWN"
FOR I = 0 TO NumDegrees STEP 5.0 X = Cx + Radius * SIN(I * Rad) Y = Cy - Radius * COS(I * Rad) PRINT #WIN.GFX, "LINE ";X1;" ";Y1;" ";X;" ";Y X1 = X Y1 = Y NEXT I
|
|
|
Post by Rod on Sept 4, 2022 8:53:22 GMT -5
The value of I, is the key here. The radius sets the size of the arc but I sets which parts of the circle are drawn. Try I=270 to 360, I=90 to 180
|
|
|
Post by Walt Decker on Sept 4, 2022 9:05:21 GMT -5
If you want an elliptical arc provide two radii. If you want to start the arc at some point other than zero (top of a circle) calculate the starting point from the center of the circle, e. g. :
Degrees = 60 DegreesStart = 327 X1 = Cx + Radius * SIN(DegreesStart * Rad) Y1 = Cy - Radius * COS(DegreesStart * Rad)
PRINT #WIN.GFX, "PLACE ";X1;" ";Y1 PRINT #WIN.GFX, "DOWN"
FOR I = DegreesStart TO DegreesStart + Degrees STEP 5.0 '<--- to draw at the top FOR I = DegreesStart TO DegreesStart - Degrees STEP -5.0 '<--- to draw at the left side
|
|
|
Post by nsbrown on Sept 4, 2022 10:35:48 GMT -5
Thank you very much everyone you have helped me a lot I really appreciate it
|
|