|
|
constexpr | IVector3 ()=default |
| | Builds a zero vector.
|
template<typename TX, typename TY, typename TZ>
requires (std::is_constructible_v<TType, TX> && std::is_constructible_v<TType, TY> && std::is_constructible_v<TType, TZ>) |
| constexpr | IVector3 (const TX &p_x, const TY &p_y, const TZ &p_z) |
| | Builds a vector from three components.
|
template<typename TOtherVector, typename TZ>
requires (std::is_constructible_v<TType, TOtherVector> && std::is_constructible_v<TType, TZ>) |
| constexpr | IVector3 (const IVector2< TOtherVector > &p_other, const TZ &p_z) |
| | Builds a vector from a 2D vector and Z component.
|
template<typename TOther>
requires std::is_constructible_v<TType, TOther> |
| constexpr | IVector3 (const IVector3< TOther > &p_other) |
| | Converting constructor from another component type.
|
template<typename TOther>
requires std::is_constructible_v<TType, TOther> |
| constexpr | IVector3 (const TOther &p_value) |
| | Fills all components with the same value.
|
| std::string | toString () const |
| | Converts the vector to a string.
|
| std::wstring | toWstring () const |
| | Converts the vector to a wide string.
|
| bool | operator== (const IVector3 &p_other) const |
| | Checks component-wise equality using SafeComparand.
|
| bool | operator!= (const IVector3 &p_other) const |
| | Negation of equality.
|
| IVector3 | operator+ (const IVector3 &p_other) const |
| | Component-wise addition.
|
| IVector3 | operator- (const IVector3 &p_other) const |
| | Component-wise subtraction.
|
| IVector3 | operator* (const IVector3 &p_other) const |
| | Component-wise multiplication.
|
| IVector3 | operator/ (const IVector3 &p_other) const |
| | Component-wise division.
|
| IVector3 | operator+ (const TType &p_scalar) const |
| | Adds a scalar to each component.
|
| IVector3 | operator- (const TType &p_scalar) const |
| | Subtracts a scalar from each component.
|
| IVector3 | operator* (const TType &p_scalar) const |
| | Multiplies each component by a scalar.
|
| IVector3 | operator/ (const TType &p_scalar) const |
| | Divides each component by a scalar.
|
| IVector3 | inverse () const |
| | Return the inverse vector.
|
| IVector3 | operator- () const |
| | Unary minus.
|
| IVector3 & | operator+= (const IVector3 &p_other) |
| | In-place component-wise addition.
|
| IVector3 & | operator-= (const IVector3 &p_other) |
| | In-place component-wise subtraction.
|
| IVector3 & | operator*= (const IVector3 &p_other) |
| | In-place component-wise multiplication.
|
| IVector3 & | operator/= (const IVector3 &p_other) |
| | In-place component-wise division.
|
| IVector3 & | operator+= (const TType &p_scalar) |
| | In-place scalar addition.
|
| IVector3 & | operator-= (const TType &p_scalar) |
| | In-place scalar subtraction.
|
| IVector3 & | operator*= (const TType &p_scalar) |
| | In-place scalar multiplication.
|
| IVector3 & | operator/= (const TType &p_scalar) |
| | In-place scalar division.
|
| bool | isZero () const |
| | Checks if all components are zero.
|
| float | squaredLength () const |
| | Computes squared vector length.
|
| float | length () const |
| | Computes Euclidean length.
|
| IVector3< float > | normalize () const |
| | Return the vector once normalized by its length.
|
| float | squaredDistance (const IVector3 &p_other) const |
| | Computes squared distance to another vector.
|
| float | distance (const IVector3 &p_other) const |
| | Computes Euclidean distance to another vector.
|
| float | dot (const IVector3 &p_other) const |
| | Computes dot product with another vector.
|
| IVector3 | cross (const IVector3 &p_other) const |
| | Computes 3D cross product.
|
| IVector2< TType > | xy () const |
| | Projects this vector into 2D using x and y components.
|
| IVector2< TType > | yz () const |
| | Projects this vector into 2D using y and z components.
|
| IVector3 | clamped (const IVector3 &p_boundA, const IVector3 &p_boundB) const |
| | Returns a clamped copy of this vector.
|
template<typename TOther>
requires std::is_constructible_v<TOther, TType> |
| constexpr | operator IVector3< TOther > () const |
| | Explicitly converts to another IVector3 component type.
|
|
template<typename TAlpha>
requires std::is_arithmetic_v<TAlpha> |
| static IVector3 | lerp (const IVector3 &p_from, const IVector3 &p_to, const TAlpha &p_alpha) |
| | Linearly interpolates between two vectors.
|
| static IVector3 | min (const IVector3 &p_a, const IVector3 &p_b) |
| | Component-wise minimum of two vectors.
|
template<typename... TOthers>
requires (sizeof...(TOthers) > 0 && (std::is_same_v<TOthers, IVector3> && ...)) |
| static IVector3 | min (const IVector3 &p_a, const IVector3 &p_b, const TOthers &...p_rest) |
| | Component-wise minimum of multiple vectors.
|
| static IVector3 | min (std::initializer_list< IVector3 > p_values) |
| | Component-wise minimum across an initializer list.
|
| static IVector3 | max (const IVector3 &p_a, const IVector3 &p_b) |
| | Component-wise maximum of two vectors.
|
template<typename... TOthers>
requires (sizeof...(TOthers) > 0 && (std::is_same_v<TOthers, IVector3> && ...)) |
| static IVector3 | max (const IVector3 &p_a, const IVector3 &p_b, const TOthers &...p_rest) |
| | Component-wise maximum of multiple vectors.
|
| static IVector3 | max (std::initializer_list< IVector3 > p_values) |
| | Component-wise maximum across an initializer list.
|
| static IVector3 | clamp (const IVector3 &p_value, const IVector3 &p_boundA, const IVector3 &p_boundB) |
| | Clamps each component of a vector between two bounds.
|
| static bool | isBetween (const IVector3 &p_value, const IVector3 &p_boundA, const IVector3 &p_boundB) |
| | Checks whether a vector lies within inclusive bounds.
|
|
| std::ostream & | operator<< (std::ostream &p_stream, const IVector3 &p_value) |
| | Streams the vector to an output stream.
|
| std::wostream & | operator<< (std::wostream &p_stream, const IVector3 &p_value) |
| | Streams the vector to a wide output stream.
|
| IVector3 | operator+ (const TType &p_scalar, const IVector3 &p_vector) |
| | Adds a scalar to a vector (scalar on the left side).
|
| IVector3 | operator- (const TType &p_scalar, const IVector3 &p_vector) |
| | Subtracts vector components from a scalar (scalar on the left side).
|
| IVector3 | operator* (const TType &p_scalar, const IVector3 &p_vector) |
| | Multiplies a scalar by a vector (scalar on the left side).
|
| IVector3 | operator/ (const TType &p_scalar, const IVector3 &p_vector) |
| | Divides a scalar by each vector component (scalar on the left side).
|
template<typename TType>
struct spk::IVector3< TType >
3D value type with common arithmetic helpers.
- Template Parameters
-
| TType | arithmetic component type; must be constructible from input values and support +, -, * and / and self assignation operator, in addition to comparisons. |
- See also
- Vector3, Vector3Int, Vector3UInt, IVector2
spk::Vector3 position{1.0f, 2.0f, 3.0f};
spk::Vector3 offset{0.5f, 0.0f, -1.0f};
const auto moved = position + offset;
const auto len = moved.
length();
float length() const
Computes Euclidean length.
Definition spk_vector3.hpp:511