TPoint

TPoint related methods


TPoint.In

function TPoint.InRect(rect: TRectangle): Boolean; constref;
function TPoint.InBox(Box: TBox): Boolean; constref;
function TPoint.InCircle(circle: TCircle): Boolean; constref;

Returns true if the TPoint is inside the specified TRectangle, TBox or TCircle.


TPoint.DistanceTo

function TPoint.DistanceTo(other:TPoint): Double; constref;

Returns distance between the current TPoint and another one.

Example:

var
  p1: TPoint = [100, 100];
  p2: TPoint = [120, 120];

begin
  WriteLn p1.DistanceTo(p2);
end;

TPoint.Rotate

function TPoint.Rotate(angle: Double; mid: TPoint): TPoint; constref;

Returns the current point rotated around mid by the specified angle.


TPoint.Magnitude

function TPoint.Magnitude(): Double; constref;

Returns the magnitude of the current point.


TPoint.Dot

function TPoint.Dot(other: TPoint): Double; constref;

Returns the dot product of 2 points


TPoint.AngleBetween

function TPoint.AngleBetween(other: TPoint): Double; constref;

Returns the angle between the current point and other.


TPoint.Offset

function TPoint.Offset(other: TPoint): TPoint; constref;
function TPoint.Offset(x, y: Int32): TPoint; constref; overload;

Offsets the current point by the values of other or by x and y.

Example

var
  p: TPoint = [100, 100];

begin
  p := p.Offset(20, 20);
  WriteLn p;
end;

TPoint.Random

function TPoint.EnsureRange(x1, y1, x2, y2: Int32): TPoint;
function TPoint.EnsureRange(b: TBox): TPoint; overload;

Returns a point that is within the specified box by setting the values that are outside of it to it’s edge.


TPoint.InRange

function TPoint.InRange(other: TPoint; dist: Double): Boolean; constref;
function TPoint.AnyInRange(other: TPointArray; dist: Double): Boolean; constref;
function TPoint.AllInRange(other: TPointArray; dist: Double): Boolean; constref;

Checks if the current point is within dist distance of other.