User Tools

Site Tools


3d_vector

Vector3

Vector3 also supports the same access methods as Vector2, with an additional z component.

Construction methods

Vector3 objects can be constructed by either:

  • Supplying the x, y, z components as floats.
  • Supplying nothing, defaulting to a zero vector.
If you need a unit Vector3, you can use the static Vector3::ZERO, Vector3::UNIT_X, and similar instead of creating new objects initialized to those values.

Utility functions

  • Dot
  • Magnitude
  • MagnitudeFast, which omits the slower square root function call.
  • Distance
  • Cross, which can either return a new Vector3 or apply to the current one depending on the arguments.
  • Angle
  • Project, always returns a new object, taking the length and direction as Vector3 objects
  • Perpendicular, always returns a new object, taking the length and direction as Vector3 objects
  • Reflection, always return a new object, taking an existing Vector3 and a normal as Vector3 objects.

Note that the typical !=, ==, *= operators are all implemented for this class.

3d_vector.txt · Last modified: 2022/05/01 18:36 by max