# Draw points based on center point, radius length, and angle

Source: Internet
Author: User
Tags cos

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

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.