static float DistanceBetweenSquared( Vector3& a, Vector3& b )

book_4_sparkGenerated
code_blocksInput

Description

The DistanceBetweenSquared method calculates the squared distance between two 3D points represented by Vector3 structures. This method is useful when you need to compare distances without the computational overhead of calculating the square root, which is required for the actual distance.

Usage

To use the DistanceBetweenSquared method, pass two Vector3 references as parameters. The method will return a float representing the squared distance between the two vectors.

This method is static and can be called without an instance of Vector3.

Example

Vector3 pointA = new Vector3(1.0f, 2.0f, 3.0f);
Vector3 pointB = new Vector3(4.0f, 5.0f, 6.0f);

float squaredDistance = Vector3.DistanceBetweenSquared(ref pointA, ref pointB);
// squaredDistance now holds the value 27.0f, which is the squared distance between pointA and pointB.