|
3DRadSpace 0.1.0Alpha
3DRadSpace is a free, simple to use, rapid application development game engine.
|
A 2D vector. More...
#include <Vector2.hpp>
Public Member Functions | |
| constexpr | Vector2 (float x=0.0f, float y=0.0f) |
| Creates a vector with the specified values. If no values are provided, it creates a zero vector. | |
| constexpr | Vector2 (std::initializer_list< float > lst) |
| Creates a vector from an initializer list of floats. | |
| float | Length () const |
| Returns the length (magnitude) of this vector. | |
| float | LengthSquared () const |
| Returns the squared length of this vector. | |
| float | Angle () const |
| Returns the angle of this vector in radians, relative to the X-axis. | |
| float | Dot (const Vector2 &v) const |
| Computes the dot product of this vector with another vector. | |
| Vector2 & | Normalize () |
| Normalizes this vector in-place. | |
| Vector2 & | operator+= (const Vector2 &v) |
| Adds another vector to this vector in-place. | |
| Vector2 | operator+ (const Vector2 &v) const |
| Adds another vector to this vector and returns the result. | |
| Vector2 & | operator- () |
| Negates this vector in-place. | |
| Vector2 | operator- () const |
| Returns the negated form of this vector. | |
| Vector2 & | operator-= (const Vector2 &v) |
| Subtracts another vector from this vector in-place. | |
| Vector2 | operator- (const Vector2 &v) const |
| Subtracts another vector from this vector and returns the result. | |
| float | operator* (const Vector2 &v) const |
| Computes the dot product of this vector with another vector. | |
| Vector2 | operator* (float s) const |
| Multiplies this vector by a scalar and returns the result. | |
| Vector2 & | operator*= (float s) |
| Multiplies this vector by a scalar in-place. | |
| Vector2 & | operator/= (float f) |
| Divides this vector by a scalar in-place. | |
| Vector2 | operator/ (float f) const |
| Divides this vector by a scalar and returns the result. | |
| Vector2 & | RotateBy (float theta) |
| Rotates this vector in-place by the specified angle. | |
| Vector2 | Rotate (const Vector2 &v, float theta) |
| Returns the specified vector rotated by the given angle. | |
| Vector2 & | Hadamard (const Vector2 &v) |
| Element-wise (Hadamard) multiplication of this vector with another vector. | |
| Vector2 & | Transform (const Matrix3x3 &m) |
| Transforms this vector in-place by the specified matrix. | |
| Vector2 | YX () const noexcept |
| Returns a vector with the components swizzled to (Y, X). | |
Static Public Member Functions | |
| static Vector2 | Zero () |
| Returns a zero vector (0, 0). | |
| static Vector2 | UnitX () |
| Returns the unit vector along the X-axis (1, 0). | |
| static Vector2 | UnitY () |
| Returns the unit vector along the Y-axis (0, 1). | |
| static Vector2 | One () |
| Returns a vector with all components set to 1 (1, 1). | |
| static float | Dot (const Vector2 &a, const Vector2 &b) |
| Computes the dot product of two vectors. | |
| static Vector2 | Normalize (const Vector2 &v) |
| Returns the normalized form of the specified vector. | |
| static Vector2 | ConvertFromNormalizedScreenSpaceToClipSpace (const Vector2 &norm) |
| Converts a normalized vector (in the range [-1, 1]) from screen space to clip space. | |
| static Vector2 | ConvertFromScreenCoordsToClipSpace (const Vector2 &point, const Vector2 &resolution) |
| Converts a point in screen coordinates to clip space, given the screen resolution. | |
| static Vector2 | Hadamard (const Vector2 &a, const Vector2 &b) |
| Element-wise (Hadamard) product of two vectors. | |
| static Vector2 | Transform (const Vector2 &v, const Matrix3x3 &m) |
| Transforms the specified vector by the given matrix. | |
Public Attributes | |
| float | X |
| X and Y components of the vector. | |
| float | Y |
A 2D vector.
Creates a vector with the specified values. If no values are provided, it creates a zero vector.
| x | The X component. |
| y | The Y component. |
|
inlineexplicitconstexpr |
Creates a vector from an initializer list of floats.
| lst | The initializer list containing up to 2 values (X, Y). |
| float Vector2::Angle | ( | ) | const |
Returns the angle of this vector in radians, relative to the X-axis.
Converts a normalized vector (in the range [-1, 1]) from screen space to clip space.
| norm | The normalized screen space vector. |
|
static |
Converts a point in screen coordinates to clip space, given the screen resolution.
| point | The point in screen coordinates. |
| resolution | The screen resolution. |
Computes the dot product of two vectors.
| a | The first vector. |
| b | The second vector. |
Computes the dot product of this vector with another vector.
| v | The other vector. |
Element-wise (Hadamard) product of two vectors.
| a | The first vector. |
| b | The second vector. |
Element-wise (Hadamard) multiplication of this vector with another vector.
| v | The vector to multiply with. |
| float Vector2::Length | ( | ) | const |
Returns the length (magnitude) of this vector.
| float Vector2::LengthSquared | ( | ) | const |
Returns the squared length of this vector.
| Vector2 & Vector2::Normalize | ( | ) |
Normalizes this vector in-place.
Returns the normalized form of the specified vector.
| v | The vector to normalize. |
|
static |
Returns a vector with all components set to 1 (1, 1).
Computes the dot product of this vector with another vector.
| v | The other vector. |
Multiplies this vector by a scalar and returns the result.
| s | The scalar value. |
Multiplies this vector by a scalar in-place.
| s | The scalar value. |
Adds another vector to this vector and returns the result.
| v | The vector to add. |
Adds another vector to this vector in-place.
| v | The vector to add. |
| Vector2 & Vector2::operator- | ( | ) |
Negates this vector in-place.
| Vector2 Vector2::operator- | ( | ) | const |
Returns the negated form of this vector.
Subtracts another vector from this vector and returns the result.
| v | The vector to subtract. |
Subtracts another vector from this vector in-place.
| v | The vector to subtract. |
Divides this vector by a scalar and returns the result.
| f | The scalar value. |
Divides this vector by a scalar in-place.
| f | The scalar value. |
Returns the specified vector rotated by the given angle.
| v | The vector to rotate. |
| theta | The rotation angle in radians. |
Rotates this vector in-place by the specified angle.
| theta | The rotation angle in radians. |
Transforms this vector in-place by the specified matrix.
| m | The matrix to transform by. |
Transforms the specified vector by the given matrix.
| v | The vector to transform. |
| m | The matrix to transform by. |
|
static |
Returns the unit vector along the X-axis (1, 0).
|
static |
Returns the unit vector along the Y-axis (0, 1).
|
noexcept |
Returns a vector with the components swizzled to (Y, X).
|
static |
Returns a zero vector (0, 0).
| float Engine3DRadSpace.Math::Vector2::X |
X and Y components of the vector.
| float Engine3DRadSpace.Math::Vector2::Y |