Table of Contents

Method DistanceSquared

Namespace
LMKit.Graphics.Geometry
Assembly
LM-Kit.NET.dll

DistanceSquared(Point, Point)

Calculates the squared distance between two points. Faster than Euclidean distance since no square root is taken.

public static double DistanceSquared(Point p1, Point p2)

Parameters

p1 Point

The first point.

p2 Point

The second point.

Returns

double

The squared Euclidean distance between p1 and p2.

DistanceSquared(IPoint, IPoint)

Calculates the squared distance between two points provided via IPoint.

public static double DistanceSquared(IPoint p1, IPoint p2)

Parameters

p1 IPoint

The first point.

p2 IPoint

The second point.

Returns

double

The squared Euclidean distance between the two points.

DistanceSquared(double, double, double, double)

Calculates the squared Euclidean distance between two 2D points provided as raw coordinate pairs.

public static double DistanceSquared(double x1, double y1, double x2, double y2)

Parameters

x1 double

The X-coordinate of the first point.

y1 double

The Y-coordinate of the first point.

x2 double

The X-coordinate of the second point.

y2 double

The Y-coordinate of the second point.

Returns

double

The squared Euclidean distance between x1, y1 and x2, y2.

Examples

double d2 = Point.DistanceSquared(0, 0, 3, 4); // 25

Remarks

This overload avoids allocating Point instances and is typically faster than Distance(double, double, double, double) since it does not compute a square root. Prefer this method when only relative distances are required.

See Also