Class Vector3

Inheritance Relationships

Derived Type

Class Documentation

class Vector3

tf2::Vector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-byte alignment when tf2::Vector3 is stored in containers. This extra component can be used by derived classes (Quaternion?) or by user Ideally, this class should be replaced by a platform optimized TF2SIMD version that keeps the data in registers

Subclassed by tf2::tf2Vector4

Public Functions

inline Vector3()

No initialization constructor.

inline Vector3(const tf2Scalar &x, const tf2Scalar &y, const tf2Scalar &z)

Constructor from scalars.

Parameters:
  • x – X value

  • y – Y value

  • z – Z value

inline Vector3 &operator+=(const Vector3 &v)

Add a vector to this one.

Parameters:

v – The vector to add to this one

inline Vector3 &operator-=(const Vector3 &v)

Subtract a vector from this one.

Parameters:

v – The vector to subtract

inline Vector3 &operator*=(const tf2Scalar &s)

Scale the vector.

Parameters:

s – Scale factor

inline Vector3 &operator/=(const tf2Scalar &s)

Inversely scale the vector.

Parameters:

s – Scale factor to divide by

inline tf2Scalar dot(const Vector3 &v) const

Return the dot product.

Parameters:

v – The other vector in the dot product

inline tf2Scalar length2() const

Return the length of the vector squared.

inline tf2Scalar length() const

Return the length of the vector.

tf2Scalar distance2(const Vector3 &v) const

Return the distance squared between the ends of this and another vector This is semantically treating the vector like a point.

tf2Scalar distance(const Vector3 &v) const

Return the distance between the ends of this and another vector This is semantically treating the vector like a point.

inline Vector3 &normalize()

Normalize this vector x^2 + y^2 + z^2 = 1.

Vector3 normalized() const

Return a normalized version of this vector.

Vector3 rotate(const Vector3 &wAxis, const tf2Scalar angle) const

Rotate this vector.

Parameters:
  • wAxis – The axis to rotate about

  • angle – The angle to rotate by

inline tf2Scalar angle(const Vector3 &v) const

Return the angle between this and another vector.

Parameters:

v – The other vector

inline Vector3 absolute() const

Return a vector will the absolute values of each element.

inline Vector3 cross(const Vector3 &v) const

Return the cross product between this and another vector.

Parameters:

v – The other vector

inline tf2Scalar triple(const Vector3 &v1, const Vector3 &v2) const
inline int minAxis() const

Return the axis with the smallest value Note return values are 0,1,2 for x, y, or z.

inline int maxAxis() const

Return the axis with the largest value Note return values are 0,1,2 for x, y, or z.

inline int furthestAxis() const
inline int closestAxis() const
inline void setInterpolate3(const Vector3 &v0, const Vector3 &v1, tf2Scalar rt)
inline Vector3 lerp(const Vector3 &v, const tf2Scalar &t) const

Return the linear interpolation between this and another vector.

Parameters:
  • v – The other vector

  • t – The ration of this to v (t = 0 => return this, t=1 => return other)

inline Vector3 &operator*=(const Vector3 &v)

Elementwise multiply this vector by the other.

Parameters:

v – The other vector

inline const tf2Scalar &getX() const

Return the x value.

inline const tf2Scalar &getY() const

Return the y value.

inline const tf2Scalar &getZ() const

Return the z value.

inline void setX(tf2Scalar x)

Set the x value.

inline void setY(tf2Scalar y)

Set the y value.

inline void setZ(tf2Scalar z)

Set the z value.

inline void setW(tf2Scalar w)

Set the w value.

inline const tf2Scalar &x() const

Return the x value.

inline const tf2Scalar &y() const

Return the y value.

inline const tf2Scalar &z() const

Return the z value.

inline const tf2Scalar &w() const

Return the w value.

inline operator tf2Scalar*()

operator tf2Scalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons.

inline operator const tf2Scalar*() const
inline bool operator==(const Vector3 &other) const
inline bool operator!=(const Vector3 &other) const
inline void setMax(const Vector3 &other)

Set each element to the max of the current values and the values of another Vector3.

Parameters:

other – The other Vector3 to compare with

inline void setMin(const Vector3 &other)

Set each element to the min of the current values and the values of another Vector3.

Parameters:

other – The other Vector3 to compare with

inline void setValue(const tf2Scalar &x, const tf2Scalar &y, const tf2Scalar &z)
inline void getSkewSymmetricMatrix(Vector3 *v0, Vector3 *v1, Vector3 *v2) const
inline void setZero()
inline bool isZero() const
inline bool fuzzyZero() const
inline bool isnan() const
void serialize(struct Vector3Data &dataOut) const
void deSerialize(const struct Vector3Data &dataIn)
void serializeFloat(struct Vector3FloatData &dataOut) const
void deSerializeFloat(const struct Vector3FloatData &dataIn)
void serializeDouble(struct Vector3DoubleData &dataOut) const
void deSerializeDouble(const struct Vector3DoubleData &dataIn)

Public Members

tf2Scalar m_floats[4]