Directly on the code: you need to reference the Math unit.
procedure Centerradiuspoint (constconst angle:double; Const var X, Y:integer); var anglehude:double; begin anglehude:the; // angle into radians X: = Round (Radius * Cos (anglehude)) + PX; Y:= Round (Radius * Sin (anglehude)) + PY; End;
C # version:
///the coordinates of the other end of the radius are calculated based on the center point, radius, and angle. Note that the Cartesian coordinate system is used/// </summary> /// <param name= "center" >Center Point</param> /// <param name= "angle" >radius Angle</param> /// <param name= "radius" >radius Length</param> /// <returns>the coordinates of the other end of the radius</returns> Public StaticPoint Centerradiuspoint (Point Center,DoubleAngleDoubleradius) {Point P=NewPoint (); DoubleAnglehude = angle * Math.PI/ the;/*angle into radians*/p.x= (int) (RADIUS * Math.Cos (anglehude)) +Center. X P.Y= (int) (RADIUS * Math.sin (anglehude)) +Center. Y returnp; }
Examples of Use:
UnitUnit1;InterfaceusesWindows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, Dialogs, Extctrls;typeTForm1=class(tform) Timer1:ttimer; procedureFormmousedown (sender:tobject; Button:tmousebutton; Shift:tshiftstate; X, Y:integer); procedureTimer1timer (Sender:tobject); Private {Private Declarations}AX, Ay:integer; R:integer; Public {Public Declarations} procedureClear (); procedureCenterradiuspoint (ConstPX, Py:integer;Constangle:double; ConstRadius:integer;varX, Y:integer); End;varForm1:tform1;Implementation{$R *.DFM}usesMath;procedureTform1.centerradiuspoint (ConstPX, Py:integer;Constangle:double; ConstRadius:integer;varX, Y:integer);varanglehude:double;beginAnglehude:= Angle * PI/ the;//angle into radiansX: = Round (Radius * Cos (anglehude)) +PX; Y:= Round (Radius * Sin (anglehude)) +PY;End;proceduretform1.clear;beginCanvas.fillrect (canvas.cliprect);End;procedureTform1.formmousedown (sender:tobject; Button:tmousebutton; Shift:tshiftstate; X, Y:integer);beginAX:=X; AY:=Y; R:=0; Clear ();End;procedureTform1.timer1timer (sender:tobject);varI:integer; X, Y:integer; t:cardinal;beginInc (R,8); T:=GetTickCount; forI: =0 to the-1 Do beginCenterradiuspoint (AX, AY, I, R, X, Y); Canvas.pixels[x, Y]:=0; End; T:= GetTickCount-T; Canvas.textout (Ten,Ten, IntToStr (T));End;End.
Draw points based on center point, radius length, and angle