ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Vector3D Class Reference

Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic. More...

#include <Vector3D.h>

Public Member Functions

 Vector3D ()
 Constructs a default Vector3D with X = 0, Y = 0, and Z = 0.
 
 Vector3D (const Vector3D &vector)
 Copy constructor. Initializes this vector with the same values as another Vector3D.
 
 Vector3D (const Vector3D *vector)
 Constructs a Vector3D by copying the components of another Vector3D pointer.
 
 Vector3D (const float &X, const float &Y, const float &Z)
 Constructs a Vector3D using specified float components.
 
Vector3D Absolute () const
 Returns a vector with the absolute value of each component.
 
Vector3D Normal () const
 Computes the squared magnitude of the vector (X^2 + Y^2 + Z^2).
 
Vector3D Add (const float &value) const
 Adds a scalar value to each component of the vector.
 
Vector3D Subtract (const float &value) const
 Subtracts a scalar value from each component of the vector.
 
Vector3D Add (const Vector3D &vector) const
 Adds another Vector3D to this one component-wise.
 
Vector3D Subtract (const Vector3D &vector) const
 Subtracts another Vector3D from this one component-wise.
 
Vector3D Multiply (const Vector3D &vector) const
 Multiplies this vector by another Vector3D component-wise.
 
Vector3D Divide (const Vector3D &vector) const
 Divides this vector by another Vector3D component-wise.
 
Vector3D Multiply (const float &scalar) const
 Scales this vector by a float (each component multiplied by scalar).
 
Vector3D Divide (const float &scalar) const
 Divides this vector by a float (each component divided by scalar).
 
Vector3D CrossProduct (const Vector3D &vector) const
 Computes the cross product of this vector with another Vector3D.
 
Vector3D UnitSphere () const
 Normalizes this vector such that its magnitude is 1 (if non-zero).
 
Vector3D Constrain (const float &minimum, const float &maximum) const
 Constrains each component of this vector between two scalar bounds.
 
Vector3D Constrain (const Vector3D &minimum, const Vector3D &maximum) const
 Constrains each component of this vector between the corresponding components of two other Vector3D objects.
 
Vector3D Permutate (const Vector3D &permutation) const
 Permutates the components of this vector using another Vector3D as an index/offset.
 
float Magnitude () const
 Computes the magnitude (length) of this vector using the formula sqrt(X^2 + Y^2 + Z^2).
 
float DotProduct (const Vector3D &vector) const
 Computes the dot product of this vector with another Vector3D.
 
float CalculateEuclideanDistance (const Vector3D &vector) const
 Calculates the Euclidean distance between this vector and another Vector3D.
 
float AverageHighestTwoComponents () const
 Computes the average of the highest two components of this vector.
 
float Max () const
 Returns the maximum component value among X, Y, Z.
 
float Min () const
 Returns the minimum component value among X, Y, Z.
 
bool IsEqual (const Vector3D &vector) const
 Checks if this vector is equal to another Vector3D component-wise.
 
String ToString () const
 Converts the vector to a string representation.
 
bool operator== (const Vector3D &vector) const
 Equality operator. Checks if two Vector3Ds are equal (component-wise).
 
bool operator!= (const Vector3D &vector) const
 Inequality operator. Checks if two Vector3Ds differ (component-wise).
 
Vector3D operator+= (const Vector3D &vector)
 In-place addition operator. Adds another vector to this one component-wise.
 
Vector3D operator= (const Vector3D &vector)
 Assignment operator. Copies another Vector3D into this one.
 
Vector3D operator+ (const Vector3D &vector) const
 Addition operator. Adds two vectors component-wise.
 
Vector3D operator- (const Vector3D &vector) const
 Subtraction operator. Subtracts two vectors component-wise.
 
Vector3D operator* (const Vector3D &vector) const
 Multiplication operator. Multiplies two vectors component-wise.
 
Vector3D operator/ (const Vector3D &vector) const
 Division operator. Divides two vectors component-wise.
 
Vector3D operator+ (const float &value) const
 Addition operator with a float scalar. Adds the scalar to each component.
 
Vector3D operator- (const float &value) const
 Subtraction operator with a float scalar. Subtracts the scalar from each component.
 
Vector3D operator* (const float &value) const
 Multiplication operator with a float scalar. Scales each component.
 
Vector3D operator/ (const float &value) const
 Division operator with a float scalar. Divides each component by value.
 

Static Public Member Functions

static Vector3D Max (const Vector3D &max, const Vector3D &input)
 Returns a new vector composed of the maximum components of max and input.
 
static Vector3D Min (const Vector3D &min, const Vector3D &input)
 Returns a new vector composed of the minimum components of min and input.
 
static Vector3D LERP (const Vector3D &start, const Vector3D &finish, const float &ratio)
 Performs linear interpolation between two Vector3Ds.
 
static Vector3D DegreesToRadians (const Vector3D &degrees)
 Converts a Vector3D of degrees to radians (component-wise).
 
static Vector3D RadiansToDegrees (const Vector3D &radians)
 Converts a Vector3D of radians to degrees (component-wise).
 
static Vector3D Normal (const Vector3D &vector)
 Returns the squared magnitude of a given vector (X^2 + Y^2 + Z^2) as a Vector3D.
 
static Vector3D Add (const Vector3D &v1, const Vector3D &v2)
 Adds two vectors (component-wise).
 
static Vector3D Subtract (const Vector3D &v1, const Vector3D &v2)
 Subtracts one vector from another (component-wise).
 
static Vector3D Multiply (const Vector3D &v1, const Vector3D &v2)
 Multiplies two vectors component-wise.
 
static Vector3D Divide (const Vector3D &v1, const Vector3D &v2)
 Divides two vectors component-wise.
 
static Vector3D Multiply (const Vector3D &vector, const float &scalar)
 Scales a Vector3D by a float, component-wise.
 
static Vector3D Multiply (const float &scalar, const Vector3D &vector)
 Scales a Vector3D by a float, component-wise (scalar on the left).
 
static Vector3D Divide (const Vector3D &vector, const float &scalar)
 Divides a Vector3D by a float, component-wise.
 
static Vector3D CrossProduct (const Vector3D &v1, const Vector3D &v2)
 Computes the cross product of two Vector3Ds.
 
static float DotProduct (const Vector3D &v1, const Vector3D &v2)
 Computes the dot product of two Vector3Ds.
 
static float CalculateEuclideanDistance (const Vector3D &v1, const Vector3D &v2)
 Calculates the Euclidean distance between two Vector3Ds.
 
static bool IsEqual (const Vector3D &v1, const Vector3D &v2)
 Checks if two Vector3Ds are equal component-wise.
 

Public Attributes

float X
 The X-component of the 3D vector.
 
float Y
 The Y-component of the 3D vector.
 
float Z
 The Z-component of the 3D vector.
 

Detailed Description

Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.

The Vector3D class defines basic 3D vector operations such as addition, subtraction, multiplication, division, dot product, cross product, and geometric queries. It also includes static functions to perform operations on multiple Vector3D objects without requiring an instance.

Definition at line 26 of file Vector3D.h.

Constructor & Destructor Documentation

◆ Vector3D() [1/4]

◆ Vector3D() [2/4]

Vector3D ( const Vector3D vector)

Copy constructor. Initializes this vector with the same values as another Vector3D.

Parameters
vectorThe Vector3D to copy from.

Definition at line 5 of file Vector3D.cpp.

◆ Vector3D() [3/4]

Vector3D ( const Vector3D vector)

Constructs a Vector3D by copying the components of another Vector3D pointer.

Parameters
vectorPointer to the Vector3D to copy from.

Definition at line 7 of file Vector3D.cpp.

◆ Vector3D() [4/4]

Vector3D ( const float X,
const float Y,
const float Z 
)

Constructs a Vector3D using specified float components.

Parameters
XThe X-component of the vector.
YThe Y-component of the vector.
ZThe Z-component of the vector.

Definition at line 9 of file Vector3D.cpp.

Member Function Documentation

◆ Absolute()

Vector3D Absolute ( ) const

Returns a vector with the absolute value of each component.

Returns
A Vector3D where each component is abs(X), abs(Y), and abs(Z).

Definition at line 12 of file Vector3D.cpp.

References X, Y, and Z.

Referenced by AverageHighestTwoComponents(), ObjectAlign::GetObjectPlanarityRatio(), and ObjectAlign::GetPlaneNormal().

◆ Add() [1/3]

Vector3D Add ( const float value) const

Adds a scalar value to each component of the vector.

Parameters
valueThe scalar to add.
Returns
A new Vector3D with components incremented by value.

Definition at line 34 of file Vector3D.cpp.

References X, Y, and Z.

Referenced by operator+(), and operator+().

◆ Add() [2/3]

Vector3D Add ( const Vector3D v1,
const Vector3D v2 
)
static

Adds two vectors (component-wise).

Parameters
v1The first Vector3D.
v2The second Vector3D.
Returns
A new Vector3D representing the sum.

Definition at line 230 of file Vector3D.cpp.

References Vector3D().

◆ Add() [3/3]

Vector3D Add ( const Vector3D vector) const

Adds another Vector3D to this one component-wise.

Parameters
vectorThe vector to add.
Returns
A new Vector3D representing the sum.

Definition at line 50 of file Vector3D.cpp.

References X, Y, and Z.

◆ AverageHighestTwoComponents()

float AverageHighestTwoComponents ( ) const

Computes the average of the highest two components of this vector.

For example, if (X, Y, Z) = (3, 7, 5), the highest two are 7 and 5, whose average is 6.

Returns
The average of the top two components.

Definition at line 165 of file Vector3D.cpp.

References Absolute(), and Mathematics::Max().

◆ CalculateEuclideanDistance() [1/2]

float CalculateEuclideanDistance ( const Vector3D v1,
const Vector3D v2 
)
static

Calculates the Euclidean distance between two Vector3Ds.

Parameters
v1The first Vector3D.
v2The second Vector3D.
Returns
The distance between v1 and v2.

Definition at line 270 of file Vector3D.cpp.

References Magnitude(), and Vector3D().

◆ CalculateEuclideanDistance() [2/2]

float CalculateEuclideanDistance ( const Vector3D vector) const

Calculates the Euclidean distance between this vector and another Vector3D.

Parameters
vectorThe other Vector3D.
Returns
The distance between the two vectors.

Definition at line 159 of file Vector3D.cpp.

References Magnitude(), Vector3D(), X, Y, and Z.

◆ Constrain() [1/2]

Vector3D Constrain ( const float minimum,
const float maximum 
) const

Constrains each component of this vector between two scalar bounds.

Parameters
minimumThe lower bound.
maximumThe upper bound.
Returns
A new Vector3D with each component constrained between [min, max].

Definition at line 120 of file Vector3D.cpp.

References Mathematics::Constrain(), X, Y, and Z.

Referenced by BoundarySphere::Update().

◆ Constrain() [2/2]

Vector3D Constrain ( const Vector3D minimum,
const Vector3D maximum 
) const

Constrains each component of this vector between the corresponding components of two other Vector3D objects.

Parameters
minimumThe lower bound vector.
maximumThe upper bound vector.
Returns
A new Vector3D with each component constrained.

Definition at line 128 of file Vector3D.cpp.

References Mathematics::Constrain(), X, Y, and Z.

◆ CrossProduct() [1/2]

Vector3D CrossProduct ( const Vector3D v1,
const Vector3D v2 
)
static

Computes the cross product of two Vector3Ds.

Parameters
v1The first Vector3D.
v2The second Vector3D.
Returns
A new Vector3D representing the cross product.

Definition at line 258 of file Vector3D.cpp.

◆ CrossProduct() [2/2]

Vector3D CrossProduct ( const Vector3D vector) const

Computes the cross product of this vector with another Vector3D.

Parameters
vectorThe other Vector3D.
Returns
A new Vector3D representing the cross product.

Definition at line 98 of file Vector3D.cpp.

References X, Y, and Z.

Referenced by CameraLayout::CalculateTransform(), Triangle3D::DidIntersect(), RotationMatrix::Inverse(), Triangle3D::Normal(), RotationMatrix::Normalize(), Rotation::QuaternionFromDirectionVectors(), and BNO055::Update().

◆ DegreesToRadians()

Vector3D DegreesToRadians ( const Vector3D degrees)
static

Converts a Vector3D of degrees to radians (component-wise).

Parameters
degreesThe vector in degrees.
Returns
A Vector3D in radians.

Definition at line 216 of file Vector3D.cpp.

References Mathematics::MPID180, and Vector3D().

◆ Divide() [1/4]

Vector3D Divide ( const float scalar) const

Divides this vector by a float (each component divided by scalar).

Parameters
scalarThe scalar divisor.
Returns
A new Vector3D after the division.

Definition at line 90 of file Vector3D.cpp.

References X, Y, and Z.

◆ Divide() [2/4]

Vector3D Divide ( const Vector3D v1,
const Vector3D v2 
)
static

Divides two vectors component-wise.

Parameters
v1The first Vector3D.
v2The second Vector3D (divisor).
Returns
A new Vector3D representing the quotient.

Definition at line 242 of file Vector3D.cpp.

References Vector3D().

◆ Divide() [3/4]

Vector3D Divide ( const Vector3D vector) const

Divides this vector by another Vector3D component-wise.

Parameters
vectorThe vector to divide by.
Returns
A new Vector3D representing the quotient.

Definition at line 74 of file Vector3D.cpp.

References X, Y, and Z.

Referenced by Object3D::GetCenterOffset(), operator/(), and operator/().

◆ Divide() [4/4]

Vector3D Divide ( const Vector3D vector,
const float scalar 
)
static

Divides a Vector3D by a float, component-wise.

Parameters
vectorThe Vector3D.
scalarThe scalar divisor.
Returns
A new Vector3D after the division.

Definition at line 254 of file Vector3D.cpp.

References Vector3D().

◆ DotProduct() [1/2]

float DotProduct ( const Vector3D v1,
const Vector3D v2 
)
static

Computes the dot product of two Vector3Ds.

Parameters
v1The first Vector3D.
v2The second Vector3D.
Returns
The dot product (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z).

Definition at line 266 of file Vector3D.cpp.

◆ DotProduct() [2/2]

float DotProduct ( const Vector3D vector) const

Computes the dot product of this vector with another Vector3D.

Parameters
vectorThe other Vector3D.
Returns
The dot product result (X1*X2 + Y1*Y2 + Z1*Z2).

Definition at line 155 of file Vector3D.cpp.

References X, Y, and Z.

Referenced by BoundarySphere::Collide(), Triangle3D::DidIntersect(), and Rotation::QuaternionFromDirectionVectors().

◆ IsEqual() [1/2]

bool IsEqual ( const Vector3D v1,
const Vector3D v2 
)
static

Checks if two Vector3Ds are equal component-wise.

Parameters
v1The first Vector3D.
v2The second Vector3D.
Returns
true if equal, otherwise false.

Definition at line 276 of file Vector3D.cpp.

◆ IsEqual() [2/2]

bool IsEqual ( const Vector3D vector) const

Checks if this vector is equal to another Vector3D component-wise.

Parameters
vectorThe Vector3D to compare.
Returns
true if equal, otherwise false.

Definition at line 184 of file Vector3D.cpp.

References X, Y, and Z.

Referenced by RotationMatrix::IsEqual(), operator!=(), and operator==().

◆ LERP()

Vector3D LERP ( const Vector3D start,
const Vector3D finish,
const float ratio 
)
static

Performs linear interpolation between two Vector3Ds.

Parameters
startThe start Vector3D.
finishThe end Vector3D.
ratioA normalized factor (0 to 1).
Returns
A new Vector3D representing the linear interpolation result.

Definition at line 210 of file Vector3D.cpp.

Referenced by Boot::Update().

◆ Magnitude()

float Magnitude ( ) const

Computes the magnitude (length) of this vector using the formula sqrt(X^2 + Y^2 + Z^2).

Returns
The length of the vector.

Definition at line 151 of file Vector3D.cpp.

References Mathematics::Sqrt(), X, Y, and Z.

Referenced by CalculateEuclideanDistance(), CalculateEuclideanDistance(), and Normal().

◆ Max() [1/2]

float Max ( ) const

Returns the maximum component value among X, Y, Z.

Returns
The maximum component.

Definition at line 176 of file Vector3D.cpp.

References Mathematics::Max(), X, Y, and Z.

Referenced by Object3D::GetMinMaxDimensions(), ObjectAlign::GetObjectCenter(), and ObjectAlign::GetObjectSize().

◆ Max() [2/2]

Vector3D Max ( const Vector3D max,
const Vector3D input 
)
static

Returns a new vector composed of the maximum components of max and input.

Parameters
maxThe first Vector3D to compare.
inputThe second Vector3D to compare.
Returns
A Vector3D taking the maximum of each component.

Definition at line 198 of file Vector3D.cpp.

References Vector3D(), X, Y, and Z.

◆ Min() [1/2]

float Min ( ) const

Returns the minimum component value among X, Y, Z.

Returns
The minimum component.

Definition at line 180 of file Vector3D.cpp.

References Mathematics::Min(), X, Y, and Z.

Referenced by Object3D::GetMinMaxDimensions(), ObjectAlign::GetObjectCenter(), and ObjectAlign::GetObjectSize().

◆ Min() [2/2]

Vector3D Min ( const Vector3D min,
const Vector3D input 
)
static

Returns a new vector composed of the minimum components of min and input.

Parameters
minThe first Vector3D to compare.
inputThe second Vector3D to compare.
Returns
A Vector3D taking the minimum of each component.

Definition at line 204 of file Vector3D.cpp.

References Vector3D(), X, Y, and Z.

◆ Multiply() [1/5]

Vector3D Multiply ( const float scalar) const

Scales this vector by a float (each component multiplied by scalar).

Parameters
scalarThe scaling factor.
Returns
A new Vector3D scaled by scalar.

Definition at line 82 of file Vector3D.cpp.

References X, Y, and Z.

◆ Multiply() [2/5]

Vector3D Multiply ( const float scalar,
const Vector3D vector 
)
static

Scales a Vector3D by a float, component-wise (scalar on the left).

Parameters
scalarThe scaling factor.
vectorThe Vector3D.
Returns
A new Vector3D scaled by scalar.

Definition at line 250 of file Vector3D.cpp.

References Vector3D().

◆ Multiply() [3/5]

Vector3D Multiply ( const Vector3D v1,
const Vector3D v2 
)
static

Multiplies two vectors component-wise.

Parameters
v1The first Vector3D.
v2The second Vector3D.
Returns
A new Vector3D representing the product.

Definition at line 238 of file Vector3D.cpp.

References Vector3D().

◆ Multiply() [4/5]

Vector3D Multiply ( const Vector3D vector) const

Multiplies this vector by another Vector3D component-wise.

Parameters
vectorThe vector to multiply with.
Returns
A new Vector3D representing the product.

Definition at line 66 of file Vector3D.cpp.

References X, Y, and Z.

Referenced by Triangle3D::DidIntersect(), RotationMatrix::Multiply(), RotationMatrix::Multiply(), Normal(), operator*(), operator*(), RotationMatrix::RotateX(), RotationMatrix::RotateY(), and RotationMatrix::RotateZ().

◆ Multiply() [5/5]

Vector3D Multiply ( const Vector3D vector,
const float scalar 
)
static

Scales a Vector3D by a float, component-wise.

Parameters
vectorThe Vector3D.
scalarThe scaling factor.
Returns
A new Vector3D scaled by scalar.

Definition at line 246 of file Vector3D.cpp.

References Vector3D().

◆ Normal() [1/2]

Vector3D Normal ( ) const

Computes the squared magnitude of the vector (X^2 + Y^2 + Z^2).

Returns
A Vector3D containing squared values of each component.

Note: This naming follows the pattern in other classes but can be confusing; some might expect Normal() to return a normalized vector.

Definition at line 20 of file Vector3D.cpp.

References Mathematics::EPSILON, Mathematics::IsClose(), Magnitude(), and Multiply().

Referenced by Normal().

◆ Normal() [2/2]

Vector3D Normal ( const Vector3D vector)
static

Returns the squared magnitude of a given vector (X^2 + Y^2 + Z^2) as a Vector3D.

Parameters
vectorThe input Vector3D.
Returns
A Vector3D containing squared values of each component.

Definition at line 224 of file Vector3D.cpp.

References Normal().

◆ operator!=()

bool operator!= ( const Vector3D vector) const

Inequality operator. Checks if two Vector3Ds differ (component-wise).

Parameters
vectorThe vector to compare with.
Returns
true if not equal, otherwise false.

Definition at line 285 of file Vector3D.cpp.

References IsEqual().

◆ operator*() [1/2]

Vector3D operator* ( const float value) const

Multiplication operator with a float scalar. Scales each component.

Parameters
valueThe scalar factor.
Returns
A new Vector3D scaled by value.

Definition at line 329 of file Vector3D.cpp.

References Multiply().

◆ operator*() [2/2]

Vector3D operator* ( const Vector3D vector) const

Multiplication operator. Multiplies two vectors component-wise.

Parameters
vectorThe right-hand side Vector3D.
Returns
A new Vector3D representing the product.

Definition at line 313 of file Vector3D.cpp.

References Multiply().

◆ operator+() [1/2]

Vector3D operator+ ( const float value) const

Addition operator with a float scalar. Adds the scalar to each component.

Parameters
valueThe scalar to add.
Returns
A new Vector3D incremented by value.

Definition at line 321 of file Vector3D.cpp.

References Add().

◆ operator+() [2/2]

Vector3D operator+ ( const Vector3D vector) const

Addition operator. Adds two vectors component-wise.

Parameters
vectorThe right-hand side Vector3D.
Returns
A new Vector3D representing the sum.

Definition at line 305 of file Vector3D.cpp.

References Add().

◆ operator+=()

Vector3D operator+= ( const Vector3D vector)

In-place addition operator. Adds another vector to this one component-wise.

Parameters
vectorThe right-hand side Vector3D.
Returns
A reference to this Vector3D after addition.

Definition at line 289 of file Vector3D.cpp.

References X, Y, and Z.

◆ operator-() [1/2]

Vector3D operator- ( const float value) const

Subtraction operator with a float scalar. Subtracts the scalar from each component.

Parameters
valueThe scalar to subtract.
Returns
A new Vector3D decremented by value.

Definition at line 325 of file Vector3D.cpp.

References Subtract().

◆ operator-() [2/2]

Vector3D operator- ( const Vector3D vector) const

Subtraction operator. Subtracts two vectors component-wise.

Parameters
vectorThe right-hand side Vector3D.
Returns
A new Vector3D representing the difference.

Definition at line 309 of file Vector3D.cpp.

References Subtract().

◆ operator/() [1/2]

Vector3D operator/ ( const float value) const

Division operator with a float scalar. Divides each component by value.

Parameters
valueThe scalar divisor.
Returns
A new Vector3D after division.

Definition at line 333 of file Vector3D.cpp.

References Divide().

◆ operator/() [2/2]

Vector3D operator/ ( const Vector3D vector) const

Division operator. Divides two vectors component-wise.

Parameters
vectorThe right-hand side Vector3D (divisor).
Returns
A new Vector3D representing the quotient.

Definition at line 317 of file Vector3D.cpp.

References Divide().

◆ operator=()

Vector3D operator= ( const Vector3D vector)

Assignment operator. Copies another Vector3D into this one.

Parameters
vectorThe vector to copy.
Returns
A reference to this Vector3D.

Definition at line 297 of file Vector3D.cpp.

References X, Y, and Z.

◆ operator==()

bool operator== ( const Vector3D vector) const

Equality operator. Checks if two Vector3Ds are equal (component-wise).

Parameters
vectorThe vector to compare with.
Returns
true if equal, otherwise false.

Definition at line 281 of file Vector3D.cpp.

References IsEqual().

◆ Permutate()

Vector3D Permutate ( const Vector3D permutation) const

Permutates the components of this vector using another Vector3D as an index/offset.

Parameters
permutationA vector whose components may dictate a specific reordering or transformation.
Returns
A new Vector3D based on the permutation logic.

Definition at line 136 of file Vector3D.cpp.

References Vector3D(), X, Y, and Z.

◆ RadiansToDegrees()

Vector3D RadiansToDegrees ( const Vector3D radians)
static

Converts a Vector3D of radians to degrees (component-wise).

Parameters
radiansThe vector in radians.
Returns
A Vector3D in degrees.

Definition at line 220 of file Vector3D.cpp.

References Mathematics::M180DPI, and Vector3D().

◆ Subtract() [1/3]

Vector3D Subtract ( const float value) const

Subtracts a scalar value from each component of the vector.

Parameters
valueThe scalar to subtract.
Returns
A new Vector3D with components decremented by value.

Definition at line 42 of file Vector3D.cpp.

References X, Y, and Z.

Referenced by operator-(), and operator-().

◆ Subtract() [2/3]

Vector3D Subtract ( const Vector3D v1,
const Vector3D v2 
)
static

Subtracts one vector from another (component-wise).

Parameters
v1The first Vector3D.
v2The second Vector3D to subtract from v1.
Returns
A new Vector3D representing the difference.

Definition at line 234 of file Vector3D.cpp.

References Vector3D().

◆ Subtract() [3/3]

Vector3D Subtract ( const Vector3D vector) const

Subtracts another Vector3D from this one component-wise.

Parameters
vectorThe vector to subtract.
Returns
A new Vector3D representing the difference.

Definition at line 58 of file Vector3D.cpp.

References X, Y, and Z.

◆ ToString()

String ToString ( ) const

Converts the vector to a string representation.

Returns
A String in the format "(X, Y, Z)".

Definition at line 189 of file Vector3D.cpp.

References Mathematics::DoubleToCleanString(), X, Y, and Z.

Referenced by Triangle3D::ToString(), EulerAngles::ToString(), EulerOrder::ToString(), Plane::ToString(), RotationMatrix::ToString(), and Transform::ToString().

◆ UnitSphere()

Vector3D UnitSphere ( ) const

Normalizes this vector such that its magnitude is 1 (if non-zero).

Returns
A new Vector3D representing the unit sphere position.

Definition at line 106 of file Vector3D.cpp.

References Mathematics::EPSILON, Mathematics::IsClose(), Vector3D(), X, Y, and Z.

Referenced by ObjectAlign::GetPlaneNormal(), ObjectAlign::GetPlaneOrientation(), NormalMaterial::GetRGB(), Triangle3D::Normal(), RotationMatrix::Normalize(), and BNO055::Update().

Member Data Documentation

◆ X

float X

The X-component of the 3D vector.

Definition at line 28 of file Vector3D.h.

Referenced by Absolute(), Add(), Add(), ObjectAlign::AlignObjects(), TriangleGroupDeformer::AxisZeroClipping(), ObjectDeformer::AxisZeroClipping(), CalculateEuclideanDistance(), TriangleGroupDeformer::CheckClipAxis(), ObjectDeformer::CheckClipAxis(), Rasterizer::CheckRasterPixel(), Rasterizer::CheckRasterPixelAccel(), BoundaryCube::CollideSphere(), Constrain(), Constrain(), RotationMatrix::ConvertCoordinateToVector(), TriangleGroupDeformer::CosineInterpolationDeformer(), ObjectDeformer::CosineInterpolationDeformer(), CrossProduct(), RotationMatrix::Determinant(), Triangle3D::DidIntersect(), Divide(), Divide(), DotProduct(), TriangleGroupDeformer::DropwaveDeform(), ObjectDeformer::DropwaveDeform(), MMC56X3::EstimateMagnetPosition(), Rotation::GetDirectionAngle(), CameraLayout::GetForwardVector(), MMC56X3::GetMagnitude(), ObjectAlign::GetObjectPlanarityRatio(), ObjectAlign::GetPlaneOrientation(), AudioReactiveGradient::GetRGB(), Oscilloscope::GetRGB(), SpectrumAnalyzer::GetRGB(), DepthMaterial::GetRGB(), Image::GetRGB(), SpiralMaterial::GetRGB(), UVMap::GetRGB(), VectorField2D::GetRGB(), MaterialMask::GetRGB(), ObjectAlign::GetTransform(), CameraLayout::GetUpVector(), IsEqual(), BoundaryCube::IsIntersecting(), BoundaryCube::IsIntersecting(), Magnitude(), Max(), Max(), Min(), Min(), Multiply(), Multiply(), operator+=(), Vector2D::operator=(), operator=(), Permutate(), ObjectDeformer::PerspectiveDeform(), Quaternion::Quaternion(), BoundaryMotionSimulator::Randomize(), BoundaryMotionSimulator::RandomRatio(), RotationMatrix::ReadjustMatrix(), RGBColor::RGBColor(), RGBColor::RGBColor(), RotationMatrix::Rotate(), Rotation::RotationMatrixToQuaternion(), TriangleGroupDeformer::SineWaveSurfaceDeform(), ObjectDeformer::SineWaveSurfaceDeform(), TriangleGroupDeformer::SinusoidalDeform(), ObjectDeformer::SinusoidalDeform(), Subtract(), Subtract(), AxisAngle::ToString(), DirectionAngle::ToString(), ToString(), RotationMatrix::Transpose(), Triangle2D::Triangle2D(), Triangle2D::Triangle2D(), UnitSphere(), MMC56X3::Update(), XenraxAnimation::Update(), and PhysicsSimulator::Update().

◆ Y

float Y

The Y-component of the 3D vector.

Definition at line 29 of file Vector3D.h.

Referenced by Absolute(), Add(), Add(), ObjectAlign::AlignObjects(), TriangleGroupDeformer::AxisZeroClipping(), ObjectDeformer::AxisZeroClipping(), CalculateEuclideanDistance(), TriangleGroupDeformer::CheckClipAxis(), ObjectDeformer::CheckClipAxis(), Rasterizer::CheckRasterPixel(), Rasterizer::CheckRasterPixelAccel(), BoundaryCube::CollideSphere(), Constrain(), Constrain(), RotationMatrix::ConvertCoordinateToVector(), TriangleGroupDeformer::CosineInterpolationDeformer(), ObjectDeformer::CosineInterpolationDeformer(), CrossProduct(), RotationMatrix::Determinant(), Triangle3D::DidIntersect(), Divide(), Divide(), DotProduct(), TriangleGroupDeformer::DropwaveDeform(), ObjectDeformer::DropwaveDeform(), MMC56X3::EstimateMagnetPosition(), CameraLayout::GetForwardVector(), MMC56X3::GetMagnitude(), ObjectAlign::GetObjectPlanarityRatio(), ObjectAlign::GetPlaneOrientation(), AudioReactiveGradient::GetRGB(), Oscilloscope::GetRGB(), SpectrumAnalyzer::GetRGB(), DepthMaterial::GetRGB(), Image::GetRGB(), SpiralMaterial::GetRGB(), UVMap::GetRGB(), VectorField2D::GetRGB(), MaterialMask::GetRGB(), ObjectAlign::GetTransform(), CameraLayout::GetUpVector(), IsEqual(), BoundaryCube::IsIntersecting(), BoundaryCube::IsIntersecting(), Magnitude(), Max(), Max(), Min(), Min(), Multiply(), Multiply(), operator+=(), Vector2D::operator=(), operator=(), Permutate(), ObjectDeformer::PerspectiveDeform(), Quaternion::Quaternion(), BoundaryMotionSimulator::Randomize(), BoundaryMotionSimulator::RandomRatio(), RotationMatrix::ReadjustMatrix(), RGBColor::RGBColor(), RGBColor::RGBColor(), RotationMatrix::Rotate(), Rotation::RotationMatrixToQuaternion(), TriangleGroupDeformer::SineWaveSurfaceDeform(), ObjectDeformer::SineWaveSurfaceDeform(), TriangleGroupDeformer::SinusoidalDeform(), ObjectDeformer::SinusoidalDeform(), Subtract(), Subtract(), AxisAngle::ToString(), DirectionAngle::ToString(), ToString(), RotationMatrix::Transpose(), Triangle2D::Triangle2D(), Triangle2D::Triangle2D(), UnitSphere(), MMC56X3::Update(), XenraxAnimation::Update(), and PhysicsSimulator::Update().

◆ Z

float Z

The Z-component of the 3D vector.

Definition at line 30 of file Vector3D.h.

Referenced by Absolute(), Add(), Add(), TriangleGroupDeformer::AxisZeroClipping(), ObjectDeformer::AxisZeroClipping(), CalculateEuclideanDistance(), TriangleGroupDeformer::CheckClipAxis(), ObjectDeformer::CheckClipAxis(), Rasterizer::CheckRasterPixel(), Rasterizer::CheckRasterPixelAccel(), BoundaryCube::CollideSphere(), Constrain(), Constrain(), RotationMatrix::ConvertCoordinateToVector(), TriangleGroupDeformer::CosineInterpolationDeformer(), ObjectDeformer::CosineInterpolationDeformer(), CrossProduct(), RotationMatrix::Determinant(), Triangle3D::DidIntersect(), Divide(), Divide(), DotProduct(), TriangleGroupDeformer::DropwaveDeform(), ObjectDeformer::DropwaveDeform(), MMC56X3::EstimateMagnetPosition(), Rotation::GetDirectionAngle(), CameraLayout::GetForwardVector(), MMC56X3::GetMagnitude(), ObjectAlign::GetObjectPlanarityRatio(), ObjectAlign::GetPlaneOrientation(), DepthMaterial::GetRGB(), CameraLayout::GetUpVector(), IsEqual(), BoundaryCube::IsIntersecting(), BoundaryCube::IsIntersecting(), Magnitude(), Max(), Max(), Min(), Min(), Multiply(), Multiply(), operator+=(), operator=(), Permutate(), ObjectDeformer::PerspectiveDeform(), Quaternion::Quaternion(), BoundaryMotionSimulator::Randomize(), BoundaryMotionSimulator::RandomRatio(), RotationMatrix::ReadjustMatrix(), RGBColor::RGBColor(), RGBColor::RGBColor(), RotationMatrix::Rotate(), Rotation::RotationMatrixToQuaternion(), TriangleGroupDeformer::SineWaveSurfaceDeform(), ObjectDeformer::SineWaveSurfaceDeform(), TriangleGroupDeformer::SinusoidalDeform(), ObjectDeformer::SinusoidalDeform(), Subtract(), Subtract(), AxisAngle::ToString(), DirectionAngle::ToString(), ToString(), RotationMatrix::Transpose(), Triangle2D::Triangle2D(), Triangle2D::Triangle2D(), UnitSphere(), MMC56X3::Update(), and PhysicsSimulator::Update().


The documentation for this class was generated from the following files: