Math¶
Math functions
Distance¶
function Distance(const X1, Y1, X2, Y2: Double): Double;
Distance¶
function Distance(const P1, P2: TPoint): Double;
LogN¶
function LogN(base, x: Double): Double;
Sar¶
function Sar(x: Integer; Shift: Byte): Integer;
Ror¶
function Ror(x: UInt32; Shift: Byte): UInt32;
Rol¶
function Rol(x: UInt32; Shift: Byte): UInt32;
DegToRad¶
function DegToRad(Deg: Double): Double;
RadToDeg¶
function RadToDeg(Rad: Double): Double;
RadNormalize¶
function RadNormalize(Rad: Double): Double;
DegNormalize¶
function DegNormalize(Deg: Double): Double;
Log2¶
function Log2(x: Double): Double;
Log10¶
function Log10(x: Double): Double;
NextPower2¶
function NextPower2(const n: Integer): Integer;
Modulo¶
function Modulo(const X, Y: Integer): Integer;
Modulo¶
function Modulo(const X, Y: Double): Double;
DeltaAngle¶
function DeltaAngle(const DegreesA, DegreesB: Double; R: Double = 360): Double;
ExpandPolygon¶
function ExpandPolygon(const Polygon: TPointArray; Amount: Integer): TPointArray;
PolygonArea¶
function PolygonArea(const Polygon: TPointArray): Double;
IsConvexPolygon¶
function IsConvexPolygon(Polygon: TPointArray): Boolean;
Returns if the polygon is convex, order does not matter. A concave polygon will return False.
TriangulatePolygon¶
function TriangulatePolygon(Polygon: TPointArray; MinArea: Double=0; MaxDepth: Int32=0): TTriangleArray;
Break the polygon into triangles, the smallest possible polygon. The order of the input does matter, if it fails, try to reverse the Poly with Poly.Reversed()
This is a custom algorithm by slacky, based around the concept of trimming “ears”, if you dont like the output, you may have more luck with rolling the Polygon before calling.
Two default params exists as well, MinArea
and MaxDepth
, they work in tandom,
MinArea
parameter is for setting a minimum size of triangles added to result, and as this method
works iteratively, removing triangles in a circle around the shape over and over, MaxDepth
refers
to the max number of rounds it has moved around the shape before it ignores MinArea
paramater.
LineInPolygon¶
function LineInPolygon(p,q: TPoint; const Polygon: TPointArray): Boolean;
Returns True if the line fits within the bounds of the polygon.
CrossProduct¶
function CrossProduct(const r, p, q: TPoint): Int64;
CrossProduct¶
function CrossProduct(const rx,ry, px,py, qx,qy: Double): Double;
LinesIntersect¶
function LinesIntersect(const P1, P2, Q1, Q2: TPoint): Boolean;
LinesIntersect¶
function LinesIntersect(const P1, P2, Q1, Q2: TPoint; out Where: TPoint): Boolean;
DistToLine¶
function DistToLine(const P, P1, P2: TPoint; out Nearest: TPoint): Double;
DistToLine¶
function DistToLine(const P, P1, P2: TPoint): Double;
PointInTriangle¶
function PointInTriangle(const P, P1, P2, P3: TPoint): Boolean;
PointInTriangle¶
function PointInTriangle(const P: TPoint; const Triangle: TTriangle): Boolean;
PointInBox¶
function PointInBox(const P: TPoint; const Box: TBox): Boolean;
PointInQuad¶
function PointInQuad(const P: TPoint; const A,B,C,D: TPoint): Boolean;
PointInPolygon¶
function PointInPolygon(const P: TPoint; const Polygon: TPointArray): Boolean;
PointInCircle¶
function PointInCircle(const P, Center: TPoint; Radius: Double): Boolean; static;
PointInEllipse¶
function PointInEllipse(const P, Center: TPoint; const YRadius, XRadius: Double): Boolean;
IsNumber¶
function IsNumber(const Value: Single): Boolean;
IsNumber¶
function IsNumber(const Value: Double): Boolean;