Facebook Twitter YouTube

class Vector3D

Defined in:  TSVector3D.h
The Vector3D class encapsulates a 3D vector.
Definition

class Vector3D : public Vec3D<float>

Member Functions
Vector3D::Set Sets all three components of a vector.
Vector3D::Normalize Normalizes a 3D vector.
Vector3D::GetVector2D Returns a reference to a Vector2D object.
Vector3D::GetPoint2D Returns a reference to a Point2D object.
Vector3D::RotateAboutX Rotates a vector about the x axis.
Vector3D::RotateAboutY Rotates a vector about the y axis.
Vector3D::RotateAboutZ Rotates a vector about the z axis.
Vector3D::RotateAboutAxis Rotates a vector about a given axis.
Constructor

Vector3D();

Vector3D(float a, float b, float c);

template <typename type> explicit Vector3D(const Vec3D<type>& v);

Parameters
a The value of the x coordinate.
b The value of the y coordinate.
c The value of the z coordinate.
v Another 3D vector, possibly with a different component type, that is converted to a Vector3D.
Description
The Vector3D class is used to store a three-dimensional direction vector having floating-point components x, y, and z. A direction vector stored in this class is assumed to have a w coordinate of 0 whenever it needs to be converted to a four-dimensional representation. Three-dimensional points (for which the w coordinate is 1) should be stored using the Point3D class.

The default constructor leaves the components of the vector undefined. If the values a, b, and c are supplied, then they are assigned to the x, y, and z coordinates of the vector, respectively.
Overloaded Operators
Vector3D& operator +=(const Vector3D& v); Adds the vector v.
Vector3D& operator -=(const Vector3D& v); Subtracts the vector v.
Vector3D& operator *=(float s); Multiplies by the scalar s.
Vector3D& operator /=(float s); Divides by the scalar s.
Vector3D& operator *=(const Vector3D& v); Calculates the componentwise product with the vector v.
Nonmember Operations
Vector3D operator -(const Vector3D& v); Returns the negation of the vector v.
Vector3D operator +(const Vector3D& a, const Vector3D& b); Returns the sum of the vectors a and b.
Vector3D operator -(const Vector3D& a, const Vector3D& b); Returns the difference of the vectors a and b.
Vector3D operator *(const Vector3D& v, float s); Returns the product of the vector v and the scalar s.
Vector3D operator *(float s, const Vector3D& v); Returns the product of the vector v and the scalar s.
Vector3D operator /(const Vector3D& v, float s); Returns the product of the vector v and the inverse of the scalar s.
Vector3D operator *(const Vector3D& a, const Vector3D& b); Returns the componentwise product of the vectors a and b
float Magnitude(const Vector3D& v); Returns the magnitude of the vector v.
float InverseMag(const Vector3D& v); Returns the inverse magnitude of the vector v.
float SquaredMag(const Vector3D& v); Returns the squared magnitude of the vector v.
float Dot(const Vector3D& a, const Vector3D& b); Returns the dot product between a and b.
Vector3D Cross(const Vector3D& a, const Vector3D& b); Returns the cross product between a and b.
Vector3D Project(const Vector3D& a, const Vector3D& b); Returns (a ⋅ b)b, which is the projection of a onto b under the assumption that the magnitude of b is one.
Vector3D Reject(const Vector3D& a, const Vector3D& b); Returns (a − a ⋅ b)b, which is the rejection of a from b under the assumption that the magnitude of b is one.
Base Classes
Vec3D Vectors use a generic base class to store their components.
See Also

Point3D

Vector4D