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

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

#include <Vector2D.h>

Public Member Functions

 Vector2D ()
 Constructs a default Vector2D with X = 0 and Y = 0.
 
 Vector2D (const Vector2D &vector)
 Copy constructor. Initializes this vector with the same values as another Vector2D.
 
 Vector2D (const float &X, const float &Y)
 Constructs a Vector2D using specified float components.
 
 Vector2D (const Vector3D &vector)
 Constructs a Vector2D from a Vector3D, discarding the Z-component.
 
Vector2D Absolute () const
 Returns a vector with the absolute value of each component.
 
Vector2D Normal () const
 Computes the squared magnitude of the vector (X^2 + Y^2).
 
Vector2D Add (const Vector2D &vector) const
 Adds this vector to another Vector2D component-wise.
 
Vector2D Subtract (const Vector2D &vector) const
 Subtracts another Vector2D from this vector component-wise.
 
Vector2D Multiply (const Vector2D &vector) const
 Multiplies this vector by another Vector2D component-wise.
 
Vector2D Divide (const Vector2D &vector) const
 Divides this vector by another Vector2D component-wise.
 
Vector2D Multiply (const float &scalar) const
 Scales this vector by a float.
 
Vector2D Divide (const float &scalar) const
 Divides this vector by a scalar.
 
float CrossProduct (const Vector2D &vector) const
 Calculates the 2D cross product of this vector with another.
 
Vector2D UnitCircle () const
 Normalizes this vector such that its magnitude is 1 (if non-zero).
 
Vector2D Constrain (const float &minimum, const float &maximum) const
 Constrains each component of this vector between the specified minimum and maximum.
 
Vector2D Constrain (const Vector2D &minimum, const Vector2D &maximum) const
 Constrains each component of this vector between the corresponding components of two other Vector2D objects.
 
Vector2D Minimum (const Vector2D &v) const
 Computes the minimum components between this vector and another Vector2D.
 
Vector2D Maximum (const Vector2D &v) const
 Computes the maximum components between this vector and another Vector2D.
 
Vector2D Rotate (const float &angle, const Vector2D &offset) const
 Rotates this vector by a specified angle (in degrees or radians) around a given offset.
 
bool CheckBounds (const Vector2D &minimum, const Vector2D &maximum) const
 Checks if this vector lies within the bounds of two other Vector2D objects.
 
float Magnitude () const
 Computes the magnitude (length) of this vector using the formula sqrt(X^2 + Y^2).
 
float DotProduct (const Vector2D &vector) const
 Computes the dot product of this vector with another Vector2D.
 
float CalculateEuclideanDistance (const Vector2D &vector) const
 Calculates the Euclidean distance between this vector and another Vector2D.
 
bool IsEqual (const Vector2D &vector) const
 Checks if this vector is equal to another Vector2D component-wise.
 
String ToString () const
 Converts the vector to a string representation.
 
bool operator== (const Vector2D &vector) const
 Equality operator. Checks if two Vector2Ds are equal (component-wise).
 
bool operator!= (const Vector2D &vector) const
 Inequality operator. Checks if two Vector2Ds differ (component-wise).
 
Vector2D operator= (const Vector2D &vector)
 Assignment operator. Copies another Vector2D into this one.
 
Vector2D operator= (const Vector3D &vector)
 Assignment operator. Copies a Vector3D into this Vector2D, discarding Z.
 
Vector2D operator+ (const Vector2D &vector) const
 Addition operator. Adds two vectors component-wise.
 
Vector2D operator- (const Vector2D &vector) const
 Subtraction operator. Subtracts two vectors component-wise.
 
Vector2D operator* (const Vector2D &vector) const
 Multiplication operator. Multiplies two vectors component-wise.
 
Vector2D operator/ (const Vector2D &vector) const
 Division operator. Divides two vectors component-wise.
 
Vector2D operator* (const float &value) const
 Multiplication operator by a float scalar (on the right).
 
Vector2D operator/ (const float &value) const
 Division operator by a float scalar.
 

Static Public Member Functions

static Vector2D Normal (const Vector2D &vector)
 Returns the squared magnitude of a given vector (X^2 + Y^2) as a Vector2D.
 
static Vector2D Add (const Vector2D &v1, const Vector2D &v2)
 Adds two vectors (component-wise).
 
static Vector2D Subtract (const Vector2D &v1, const Vector2D &v2)
 Subtracts one vector from another (component-wise).
 
static Vector2D Multiply (const Vector2D &v1, const Vector2D &v2)
 Multiplies two vectors component-wise.
 
static Vector2D Divide (const Vector2D &v1, const Vector2D &v2)
 Divides two vectors component-wise.
 
static Vector2D Multiply (const Vector2D &vector, const float &scalar)
 Scales a Vector2D by a float, component-wise.
 
static Vector2D Multiply (const float &scalar, const Vector2D &vector)
 Scales a Vector2D by a float, component-wise (scalar on the left).
 
static Vector2D Divide (const Vector2D &vector, const float &scalar)
 Divides a Vector2D by a scalar, component-wise.
 
static float CrossProduct (const Vector2D &v1, const Vector2D &v2)
 Computes the 2D cross product of two vectors, returning a scalar (Z-component in 3D).
 
static float DotProduct (const Vector2D &v1, const Vector2D &v2)
 Computes the dot product of two Vector2Ds.
 
static float CalculateEuclideanDistance (const Vector2D &v1, const Vector2D &v2)
 Calculates the Euclidean distance between two Vector2Ds.
 
static bool IsEqual (const Vector2D &v1, const Vector2D &v2)
 Checks if two Vector2Ds are equal component-wise.
 
static Vector2D Minimum (const Vector2D &v1, const Vector2D &v2)
 Returns a new vector with the minimum components of two Vector2Ds.
 
static Vector2D Maximum (const Vector2D &v1, const Vector2D &v2)
 Returns a new vector with the maximum components of two Vector2Ds.
 
static Vector2D LERP (const Vector2D &start, const Vector2D &finish, const float &ratio)
 Performs linear interpolation between two Vector2Ds.
 
static Vector2D DegreesToRadians (const Vector2D &degrees)
 Converts a vector of degrees to radians (component-wise).
 
static Vector2D RadiansToDegrees (const Vector2D &radians)
 Converts a vector of radians to degrees (component-wise).
 
static bool LineSegmentsIntersect (const Vector2D &p1, const Vector2D &p2, const Vector2D &q1, const Vector2D &q2)
 Checks if two line segments defined by (p1, p2) and (q1, q2) intersect in 2D space.
 

Public Attributes

float X
 The X-component of the 2D vector.
 
float Y
 The Y-component of the 2D vector.
 

Detailed Description

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

The Vector2D class defines basic 2D 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 Vector2D objects without requiring an instance.

Definition at line 27 of file Vector2D.h.

Constructor & Destructor Documentation

◆ Vector2D() [1/4]

◆ Vector2D() [2/4]

Vector2D ( const Vector2D vector)

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

Parameters
vectorThe Vector2D to copy from.

Definition at line 5 of file Vector2D.cpp.

◆ Vector2D() [3/4]

Vector2D ( const float X,
const float Y 
)

Constructs a Vector2D using specified float components.

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

Definition at line 7 of file Vector2D.cpp.

◆ Vector2D() [4/4]

Vector2D ( const Vector3D vector)

Constructs a Vector2D from a Vector3D, discarding the Z-component.

Parameters
vectorThe Vector3D to convert (Z is ignored).

Definition at line 9 of file Vector2D.cpp.

Member Function Documentation

◆ Absolute()

Vector2D Absolute ( ) const

Returns a vector with the absolute value of each component.

Returns
A Vector2D where each component is abs(X) and abs(Y).

Definition at line 11 of file Vector2D.cpp.

References X, and Y.

◆ Add() [1/2]

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

Adds two vectors (component-wise).

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

Definition at line 203 of file Vector2D.cpp.

References Vector2D().

◆ Add() [2/2]

Vector2D Add ( const Vector2D vector) const

Adds this vector to another Vector2D component-wise.

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

Definition at line 32 of file Vector2D.cpp.

References X, and Y.

Referenced by operator+().

◆ CalculateEuclideanDistance() [1/2]

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

Calculates the Euclidean distance between two Vector2Ds.

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

Definition at line 239 of file Vector2D.cpp.

References Magnitude(), and Vector2D().

◆ CalculateEuclideanDistance() [2/2]

float CalculateEuclideanDistance ( const Vector2D vector) const

Calculates the Euclidean distance between this vector and another Vector2D.

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

Definition at line 150 of file Vector2D.cpp.

References Magnitude(), Vector2D(), X, and Y.

Referenced by Fisheye::ApplyEffect(), and Magnet::ApplyEffect().

◆ CheckBounds()

bool CheckBounds ( const Vector2D minimum,
const Vector2D maximum 
) const

Checks if this vector lies within the bounds of two other Vector2D objects.

Parameters
minimumThe lower bound Vector2D.
maximumThe upper bound Vector2D.
Returns
true if within bounds, otherwise false.

Definition at line 138 of file Vector2D.cpp.

References X, and Y.

◆ Constrain() [1/2]

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

Constrains each component of this vector between the specified minimum and maximum.

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

Definition at line 96 of file Vector2D.cpp.

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

◆ Constrain() [2/2]

Vector2D Constrain ( const Vector2D minimum,
const Vector2D maximum 
) const

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

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

Definition at line 103 of file Vector2D.cpp.

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

◆ CrossProduct() [1/2]

float CrossProduct ( const Vector2D v1,
const Vector2D v2 
)
static

Computes the 2D cross product of two vectors, returning a scalar (Z-component in 3D).

Parameters
v1The first Vector2D.
v2The second Vector2D.
Returns
The scalar cross product (v1.x*v2.y - v1.y*v2.x).

Definition at line 231 of file Vector2D.cpp.

◆ CrossProduct() [2/2]

float CrossProduct ( const Vector2D vector) const

Calculates the 2D cross product of this vector with another.

For 2D vectors, the "cross product" reduces to a scalar, which is conceptually the Z-component of the 3D cross product.

Parameters
vectorThe other Vector2D.
Returns
The scalar cross product result.

Definition at line 80 of file Vector2D.cpp.

References X, and Y.

◆ DegreesToRadians()

Vector2D DegreesToRadians ( const Vector2D degrees)
static

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

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

Definition at line 189 of file Vector2D.cpp.

References Mathematics::MPID180, and Vector2D().

◆ Divide() [1/4]

Vector2D Divide ( const float scalar) const

Divides this vector by a scalar.

Parameters
scalarThe scalar divisor.
Returns
A new Vector2D after division by scalar.

Definition at line 70 of file Vector2D.cpp.

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

◆ Divide() [2/4]

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

Divides two vectors component-wise.

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

Definition at line 215 of file Vector2D.cpp.

References Vector2D().

◆ Divide() [3/4]

Vector2D Divide ( const Vector2D vector) const

Divides this vector by another Vector2D component-wise.

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

Definition at line 53 of file Vector2D.cpp.

References X, and Y.

Referenced by AudioReactiveGradient::AudioReactiveGradient(), operator/(), operator/(), Oscilloscope::Oscilloscope(), AudioReactiveGradient::SetSize(), Oscilloscope::SetSize(), SpectrumAnalyzer::SetSize(), and SpectrumAnalyzer::SpectrumAnalyzer().

◆ Divide() [4/4]

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

Divides a Vector2D by a scalar, component-wise.

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

Definition at line 227 of file Vector2D.cpp.

References Vector2D().

◆ DotProduct() [1/2]

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

Computes the dot product of two Vector2Ds.

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

Definition at line 235 of file Vector2D.cpp.

◆ DotProduct() [2/2]

float DotProduct ( const Vector2D vector) const

Computes the dot product of this vector with another Vector2D.

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

Definition at line 146 of file Vector2D.cpp.

References X, and Y.

◆ IsEqual() [1/2]

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

Checks if two Vector2Ds are equal component-wise.

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

Definition at line 245 of file Vector2D.cpp.

◆ IsEqual() [2/2]

bool IsEqual ( const Vector2D vector) const

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

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

Definition at line 156 of file Vector2D.cpp.

References X, and Y.

Referenced by operator!=(), and operator==().

◆ LERP()

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

Performs linear interpolation between two Vector2Ds.

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

Definition at line 183 of file Vector2D.cpp.

◆ LineSegmentsIntersect()

bool LineSegmentsIntersect ( const Vector2D p1,
const Vector2D p2,
const Vector2D q1,
const Vector2D q2 
)
static

Checks if two line segments defined by (p1, p2) and (q1, q2) intersect in 2D space.

Parameters
p1Start of the first segment.
p2End of the first segment.
q1Start of the second segment.
q2End of the second segment.
Returns
true if the segments intersect, otherwise false.

Definition at line 249 of file Vector2D.cpp.

References Mathematics::EPSILON.

◆ Magnitude()

float Magnitude ( ) const

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

Returns
The length of the vector.

Definition at line 142 of file Vector2D.cpp.

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

Referenced by CalculateEuclideanDistance(), CalculateEuclideanDistance(), SpiralMaterial::GetRGB(), Normal(), and UnitCircle().

◆ Maximum() [1/2]

Vector2D Maximum ( const Vector2D v) const

Computes the maximum components between this vector and another Vector2D.

Parameters
vThe other Vector2D.
Returns
A new Vector2D taking the maximum of X and Y components.

Definition at line 117 of file Vector2D.cpp.

References X, and Y.

Referenced by BoundingBox2D::UpdateBounds().

◆ Maximum() [2/2]

Vector2D Maximum ( const Vector2D v1,
const Vector2D v2 
)
static

Returns a new vector with the maximum components of two Vector2Ds.

Parameters
v1The first Vector2D.
v2The second Vector2D.
Returns
A Vector2D with per-component maximums.

Definition at line 176 of file Vector2D.cpp.

◆ Minimum() [1/2]

Vector2D Minimum ( const Vector2D v) const

Computes the minimum components between this vector and another Vector2D.

Parameters
vThe other Vector2D.
Returns
A new Vector2D taking the minimum of X and Y components.

Definition at line 110 of file Vector2D.cpp.

References X, and Y.

Referenced by BoundingBox2D::UpdateBounds().

◆ Minimum() [2/2]

Vector2D Minimum ( const Vector2D v1,
const Vector2D v2 
)
static

Returns a new vector with the minimum components of two Vector2Ds.

Parameters
v1The first Vector2D.
v2The second Vector2D.
Returns
A Vector2D with per-component minimums.

Definition at line 169 of file Vector2D.cpp.

◆ Multiply() [1/5]

Vector2D Multiply ( const float scalar) const

Scales this vector by a float.

Parameters
scalarThe scalar value.
Returns
A new Vector2D scaled by scalar.

Definition at line 60 of file Vector2D.cpp.

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

◆ Multiply() [2/5]

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

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

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

Definition at line 223 of file Vector2D.cpp.

References Vector2D().

◆ Multiply() [3/5]

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

Multiplies two vectors component-wise.

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

Definition at line 211 of file Vector2D.cpp.

References Vector2D().

◆ Multiply() [4/5]

Vector2D Multiply ( const Vector2D vector) const

Multiplies this vector by another Vector2D component-wise.

Parameters
vectorThe vector to multiply by.
Returns
A new Vector2D representing the product.

Definition at line 46 of file Vector2D.cpp.

References X, and Y.

Referenced by Normal(), operator*(), operator*(), and ProtogenProject::UpdateFace().

◆ Multiply() [5/5]

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

Scales a Vector2D by a float, component-wise.

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

Definition at line 219 of file Vector2D.cpp.

References Vector2D().

◆ Normal() [1/2]

Vector2D Normal ( ) const

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

Returns
A Vector2D whose components are squared. (Typically used as an internal helper.)

Definition at line 18 of file Vector2D.cpp.

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

Referenced by Normal().

◆ Normal() [2/2]

Vector2D Normal ( const Vector2D vector)
static

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

Note: This function name can be misleading since "Normal" typically implies a normalized vector. Here, it is used as in "square of the magnitude" or "norm".

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

Definition at line 197 of file Vector2D.cpp.

References Normal().

◆ operator!=()

bool operator!= ( const Vector2D vector) const

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

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

Definition at line 273 of file Vector2D.cpp.

References IsEqual().

◆ operator*() [1/2]

Vector2D operator* ( const float value) const

Multiplication operator by a float scalar (on the right).

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

Definition at line 307 of file Vector2D.cpp.

References Multiply().

◆ operator*() [2/2]

Vector2D operator* ( const Vector2D vector) const

Multiplication operator. Multiplies two vectors component-wise.

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

Definition at line 299 of file Vector2D.cpp.

References Multiply().

◆ operator+()

Vector2D operator+ ( const Vector2D vector) const

Addition operator. Adds two vectors component-wise.

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

Definition at line 291 of file Vector2D.cpp.

References Add().

◆ operator-()

Vector2D operator- ( const Vector2D vector) const

Subtraction operator. Subtracts two vectors component-wise.

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

Definition at line 295 of file Vector2D.cpp.

References Subtract().

◆ operator/() [1/2]

Vector2D operator/ ( const float value) const

Division operator by a float scalar.

Parameters
valueThe scalar divisor.
Returns
A new Vector2D after division by value.

Definition at line 311 of file Vector2D.cpp.

References Divide().

◆ operator/() [2/2]

Vector2D operator/ ( const Vector2D vector) const

Division operator. Divides two vectors component-wise.

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

Definition at line 303 of file Vector2D.cpp.

References Divide().

◆ operator=() [1/2]

Vector2D operator= ( const Vector2D vector)

Assignment operator. Copies another Vector2D into this one.

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

Definition at line 277 of file Vector2D.cpp.

References X, and Y.

◆ operator=() [2/2]

Vector2D operator= ( const Vector3D vector)

Assignment operator. Copies a Vector3D into this Vector2D, discarding Z.

Parameters
vectorThe Vector3D to copy from.
Returns
A reference to this Vector2D.

Definition at line 284 of file Vector2D.cpp.

References X, Vector3D::X, Y, and Vector3D::Y.

◆ operator==()

bool operator== ( const Vector2D vector) const

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

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

Definition at line 269 of file Vector2D.cpp.

References IsEqual().

◆ RadiansToDegrees()

Vector2D RadiansToDegrees ( const Vector2D radians)
static

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

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

Definition at line 193 of file Vector2D.cpp.

References Mathematics::M180DPI, and Vector2D().

◆ Rotate()

Vector2D Rotate ( const float angle,
const Vector2D offset 
) const

Rotates this vector by a specified angle (in degrees or radians) around a given offset.

Parameters
angleThe angle of rotation.
offsetThe origin about which to rotate.
Returns
A new Vector2D representing the rotated vector.

Definition at line 124 of file Vector2D.cpp.

References Mathematics::MPID180, Vector2D(), X, and Y.

Referenced by AudioReactiveGradient::GetRGB(), Oscilloscope::GetRGB(), SpectrumAnalyzer::GetRGB(), Image::GetRGB(), and VectorField2D::GetVectorAtPosition().

◆ Subtract() [1/2]

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

Subtracts one vector from another (component-wise).

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

Definition at line 207 of file Vector2D.cpp.

References Vector2D().

◆ Subtract() [2/2]

Vector2D Subtract ( const Vector2D vector) const

Subtracts another Vector2D from this vector component-wise.

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

Definition at line 39 of file Vector2D.cpp.

References X, and Y.

Referenced by operator-().

◆ ToString()

String ToString ( ) const

Converts the vector to a string representation.

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

Definition at line 160 of file Vector2D.cpp.

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

Referenced by Triangle2D::ToString().

◆ UnitCircle()

Vector2D UnitCircle ( ) const

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

Returns
A unit circle vector pointing in the same direction.

Definition at line 84 of file Vector2D.cpp.

References Mathematics::EPSILON, Mathematics::IsClose(), Magnitude(), Vector2D(), X, and Y.

Member Data Documentation

◆ X

float X

The X-component of the 2D vector.

Definition at line 29 of file Vector2D.h.

Referenced by Absolute(), Add(), ObjectAlign::AlignObjects(), ObjectAlign::AlignObjectsNoScale(), HeadsUpDisplay::ApplyEffect(), Fisheye::ApplyEffect(), Magnet::ApplyEffect(), PhaseOffsetR::ApplyEffect(), PhaseOffsetY::ApplyEffect(), BoundingBox2D::BoundingBox2D(), CalculateEuclideanDistance(), CheckBounds(), Rasterizer::CheckRasterPixel(), Rasterizer::CheckRasterPixelAccel(), Constrain(), Constrain(), BoundingBox2D::Contains(), Node::CreateChildNodes(), CrossProduct(), Triangle2D::DidIntersectSAT(), Divide(), Divide(), DotProduct(), HeadsUpDisplay::EnableBitFaceRender(), AudioReactiveGradient::GetRGB(), Oscilloscope::GetRGB(), SpectrumAnalyzer::GetRGB(), Image::GetRGB(), SpiralMaterial::GetRGB(), UVMap::GetRGB(), VectorField2D::GetRGB(), ObjectAlign::GetTransform(), VectorField2D::GetVectorAtPosition(), IsEqual(), Circle::IsInShape(), Ellipse::IsInShape(), Rectangle::IsInShape(), Magnitude(), Maximum(), Minimum(), VectorField2D::MovingSquareField(), Multiply(), Multiply(), VectorField2D::ObjectField(), operator=(), operator=(), BoundingBox2D::Overlaps(), BoundingBox2D::Overlaps(), Rasterizer::Rasterize(), Rotate(), VectorField2D::SetPosition(), VectorField2D::SetSize(), Menu::SetSize(), VectorField2D::SineField(), VectorField2D::SpiralField(), VectorField2D::StepField(), Subtract(), ToString(), Triangle2D::Triangle2D(), Triangle2D::Triangle2D(), Triangle2D::Triangle2D(), UnitCircle(), Menu::Update(), BoundingBox2D::UpdateBounds(), and ProtogenProject::UpdateFace().

◆ Y

float Y

The Y-component of the 2D vector.

Definition at line 30 of file Vector2D.h.

Referenced by Absolute(), Add(), ObjectAlign::AlignObjects(), ObjectAlign::AlignObjectsNoScale(), HeadsUpDisplay::ApplyEffect(), Fisheye::ApplyEffect(), Magnet::ApplyEffect(), PhaseOffsetR::ApplyEffect(), PhaseOffsetX::ApplyEffect(), BoundingBox2D::BoundingBox2D(), CalculateEuclideanDistance(), CheckBounds(), Rasterizer::CheckRasterPixel(), Rasterizer::CheckRasterPixelAccel(), Constrain(), Constrain(), BoundingBox2D::Contains(), Node::CreateChildNodes(), CrossProduct(), Triangle2D::DidIntersectSAT(), Divide(), Divide(), DotProduct(), HeadsUpDisplay::EnableBitFaceRender(), AudioReactiveGradient::GetRGB(), Oscilloscope::GetRGB(), SpectrumAnalyzer::GetRGB(), Image::GetRGB(), SpiralMaterial::GetRGB(), UVMap::GetRGB(), VectorField2D::GetRGB(), ObjectAlign::GetTransform(), VectorField2D::GetVectorAtPosition(), IsEqual(), Circle::IsInShape(), Ellipse::IsInShape(), Rectangle::IsInShape(), Magnitude(), Maximum(), Minimum(), VectorField2D::MovingSquareField(), Multiply(), Multiply(), VectorField2D::ObjectField(), operator=(), operator=(), BoundingBox2D::Overlaps(), BoundingBox2D::Overlaps(), Rasterizer::Rasterize(), Rotate(), VectorField2D::SetPosition(), VectorField2D::SetSize(), VectorField2D::SineField(), VectorField2D::SpiralField(), VectorField2D::StepField(), Subtract(), ToString(), Triangle2D::Triangle2D(), Triangle2D::Triangle2D(), Triangle2D::Triangle2D(), UnitCircle(), BoundingBox2D::UpdateBounds(), and ProtogenProject::UpdateFace().


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