static float DistanceSquared( Vector2& a, Vector2& b )
float DistanceSquared( Vector2 target )

robot_2Generated
code_blocksInput

Description

The DistanceSquared method calculates the squared distance between two 2D vectors. This method is useful when you need to compare distances without the computational cost of calculating the square root, which is required for the actual distance.

Usage

Use this method when you need to determine the relative distance between two points in 2D space, and the exact distance is not necessary. This can be particularly useful in performance-critical applications where many distance comparisons are needed.

Example

Vector2 pointA = new Vector2(1.0f, 2.0f);
Vector2 pointB = new Vector2(4.0f, 6.0f);

float squaredDistance = Vector2.DistanceSquared(ref pointA, ref pointB);
// squaredDistance will be 25.0f, which is the squared distance between pointA and pointB.