Skip to content

Vector3Extensions

Namespace: SideXP.Core

public static class Vector3Extensions

Extension functions for Vector3 values.

Methods

Min(Vector3, float)

public static Vector3 Min(Vector3 vector, float min)

Returns a new Vector3 with its values superior or equal to the given minimum value.

Parameters

  • vector: The input vector to compute.
  • min: The minimum value of the given vector.

Returns

Returns the computed vector.

Max(Vector3, float)

public static Vector3 Max(Vector3 vector, float max)

Returns a new Vector3 instance with its values inferior or equal to the given maximum value.

Parameters

  • max: The maximum value of the given vector.
  • vector: The input vector to compute.

Returns

Returns the computed vector.

Translate(Vector3[], Vector3, bool)

public static Vector3[] Translate(Vector3[] points, Vector3 translation, bool inPlace = false)

Translates the given points.

Parameters

  • points: The points you want to translate.
  • translation: The translation vector.
  • inPlace: If enabled, the input array is modified in-place, instead of returning a new array.

Returns

Returns the translated points.

To2D(IList<Vector3>)

public static Vector2[] To2D(IList<Vector3> points)

Converts this list into a Vector2 array.

Parameters

  • points: The points you want to convert.

Returns

Returns the processed array.

Barycentre(IList<Vector3>)

public static Vector3 Barycentre(IList<Vector3> points)

Computes the barycentre of the given points. Barycentre formula:

.               ->                ->
->    weightA * OA + weightN... * ON...
OG = ___________________________________
.            weightA + weightN...

Parameters

  • points: The points from which you want to compute the barycentre.

Returns

Returns the computed barycentre.

Barycentre(IList<(Vector3, float)>)

public static Vector3 Barycentre(IList<(Vector3, float)> weightedPoints)

Parameters

  • weightedPoints: The points from which you want to compute the barycentre, and their associated weight. The more the weight value, the closer the barycentre to this point.