PtInCircle (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code example returns whether a given TPoint belongs to the area of a circle. This is done with the help of PtInCircle routine.

Code

...
uses
  System.SysUtils, System.Types;

var
  Point, CenterOfCircle: TPoint;
  CircleRadius: Integer;

begin
    Point.X := 5;
    Point.Y := 6;

    CenterOfCircle.X := 12;
    CenterOfCircle.Y := 15;

    CircleRadius := 5;

    if PtInCircle(Point, CenterOfCircle, CircleRadius) then
      writeln('The point appears to be on the surface of the circle')
    else 
      writeln('The point does not belong to the surface of the circle');
    { The PtInCircle function returns a Boolean value. In this particular case, Point is not in the circle area }
end.

Uses