XVector3#
-
template<typename T = float>
class XVector3# Template class representing a 3-dimensional vector with x, y, and z components.
A template-based 3D vector class that provides basic vector operations including arithmetic operations, comparisons, and type conversions. This class is commonly used for 3D coordinates, directions, and mathematical computations in graphics and physics applications.
Note
This class includes validation macros in debug builds to ensure finite values
- Template Parameters:
T – The numeric type for vector components (defaults to float)
Public Functions
-
inline XVector3()#
Default constructor initializes all components to zero.
-
inline XVector3(T a)#
Constructor that initializes all components to the same value.
- Parameters:
a – [in] Value to assign to all components
-
inline XVector3(const T *p)#
Constructor that initializes components from an array.
- Parameters:
p – [in] Pointer to array of at least 3 elements
-
inline XVector3(T x_, T y_, T z_)#
Constructor that initializes components with specific values.
- Parameters:
x_ – [in] X component value
y_ – [in] Y component value
z_ – [in] Z component value
-
inline operator T*()#
Conversion operator to non-const pointer to components.
- Returns:
Pointer to the first component (x)
-
inline operator const T*() const#
Conversion operator to const pointer to components.
- Returns:
Const pointer to the first component (x)
-
inline void Set(T x_, T y_, T z_)#
Sets all three components of the vector.
- Parameters:
x_ – [in] New x component value
y_ – [in] New y component value
z_ – [in] New z component value
-
inline XVector3<T> operator*(T scale) const#
Scalar multiplication operator.
- Parameters:
scale – [in] Scalar value to multiply with
- Returns:
New vector with each component multiplied by scale
-
inline XVector3<T> operator/(T scale) const#
Scalar division operator.
- Parameters:
scale – [in] Scalar value to divide by
- Returns:
New vector with each component divided by scale
-
inline XVector3<T> operator+(const XVector3<T> &v) const#
Vector addition operator.
- Parameters:
v – [in] Vector to add
- Returns:
New vector that is the sum of this vector and v
-
inline XVector3<T> operator-(const XVector3<T> &v) const#
Vector subtraction operator.
- Parameters:
v – [in] Vector to subtract
- Returns:
New vector that is the difference of this vector and v
-
inline XVector3<T> operator/(const XVector3<T> &v) const#
Component-wise vector division operator.
- Parameters:
v – [in] Vector to divide by component-wise
- Returns:
New vector with components divided element-wise
-
inline XVector3<T> operator*(const XVector3<T> &v) const#
Component-wise vector multiplication operator.
- Parameters:
v – [in] Vector to multiply component-wise
- Returns:
New vector with components multiplied element-wise
-
inline XVector3<T> &operator*=(T scale)#
Scalar multiplication assignment operator.
- Parameters:
scale – [in] Scalar value to multiply with
- Returns:
Reference to this vector after multiplication
-
inline XVector3<T> &operator/=(T scale)#
Scalar division assignment operator.
- Parameters:
scale – [in] Scalar value to divide by
- Returns:
Reference to this vector after division
-
inline XVector3<T> &operator+=(const XVector3<T> &v)#
Vector addition assignment operator.
- Parameters:
v – [in] Vector to add
- Returns:
Reference to this vector after addition
-
inline XVector3<T> &operator-=(const XVector3<T> &v)#
Vector subtraction assignment operator.
- Parameters:
v – [in] Vector to subtract
- Returns:
Reference to this vector after subtraction
-
inline XVector3<T> &operator/=(const XVector3<T> &v)#
Component-wise vector division assignment operator.
- Parameters:
v – [in] Vector to divide by component-wise
- Returns:
Reference to this vector after component-wise division
-
inline XVector3<T> &operator*=(const XVector3<T> &v)#
Component-wise vector multiplication assignment operator.
- Parameters:
v – [in] Vector to multiply component-wise
- Returns:
Reference to this vector after component-wise multiplication
-
inline bool operator!=(const XVector3<T> &v) const#
Inequality comparison operator.
- Parameters:
v – [in] Vector to compare with
- Returns:
True if any component differs, false if all components are equal
-
inline XVector3<T> operator-() const#
Unary negation operator.
- Returns:
New vector with all components negated
-
inline void Validate()#
Validates vector components for finite values.
Calls internal validation macro to check for NaN and infinite values