template<typename Scalar, size_t Dimensions>
vector struct
An N-dimensional vector.
Template parameters | |
---|---|
Scalar | The vector's scalar type. |
Dimensions | The number of dimensions in the vector. |
Public types
- using scalar_type = Scalar
- The vector's scalar type.
Public static variables
- static size_t dimensions constexpr
- The number of dimensions in the vector.
Public static functions
- static auto cross(const vector& v1, const vector& v2) -> vector constexpr noexcept
- Returns the cross product of two vectors.
-
static auto dot(const vector& v1,
const vector& v2) -> scalar_
type constexpr noexcept - Returns the dot product of two vectors.
- static auto normalize(const vector& v) -> vector noexcept
- Normalizes a vector.
Constructors, destructors, conversion operators
- operator bool() const explicit constexpr noexcept
- Returns true if any of the vector's scalar components are non-zero.
- vector() defaulted noexcept
- Default constructor. Does not initialize the vector.
- vector(const vector&) defaulted constexpr noexcept
- Copy constructor.
-
vector(scalar_
type x, scalar_ type y) constexpr noexcept - Componentwise constructor.
-
vector(scalar_
type x, scalar_ type y, scalar_ type z = scalar_ type{}) constexpr noexcept - Componentwise constructor.
-
vector(scalar_
type x, scalar_ type y, scalar_ type z = scalar_ type{}, scalar_ type w = scalar_ type{}) constexpr noexcept - Componentwise constructor.
-
vector(scalar_
type broadcast) explicit constexpr noexcept - Broadcast constructor.
-
vector(const scalar_
type* x) explicit constexpr noexcept - Pointer-to-scalars constructor.
Public functions
- auto cross(const vector& v2) const -> vector constexpr noexcept
- Returns the cross product of this vector and another.
-
auto data() const -> constscalar_
type* constexpr noexcept - Returns a pointer to the first scalar in the vector.
-
auto data() -> scalar_
type* noexcept - Returns a pointer to the first scalar in the vector.
-
auto dot(const vector& v2) const -> scalar_
type constexpr noexcept - Returns the dot product of this vector and another.
-
auto length() const -> scalar_
type noexcept - Returns the length of a vector.
-
auto length_squared() const -> scalar_
type constexpr noexcept - Returns the squared-length of a vector.
- auto normalize() -> vector& noexcept
- Normalizes the vector (in-place).
- auto operator=(const vector&) -> vector& defaulted noexcept
- Copy-assignment operator.
-
auto operator[](size_t idx) -> scalar_
type& noexcept - Scalar subscript operator.
-
auto operator[](size_t idx) const -> constscalar_
type& constexpr noexcept - Scalar subscript operator.
Public variables
-
scalar_
type scalars - The vector's scalar values.
Compatibility with UE4
- operator::FVector() const noexcept
- Converts a 3D vector into a UE4 FVector.
- operator::FVector2D() const noexcept
- Converts a 2D vector into a UE4 FVector2D.
- operator::FVector4() const noexcept
- Converts a 4D vector into a UE4 FVector4.
- vector(const ::FVector2D& vec) noexcept
- Constructs a 2D vector from a UE4 FVector2D.
- vector(const ::FVector& vec) noexcept
- Constructs a 3D vector from a UE4 FVector.
- vector(const ::FVector4& vec) noexcept
- Constructs a 4D vector from a UE4 FVector4.
Friends
- auto operator*(const vector& v1, const vector& v2) -> vector constexpr noexcept
- Componentwise-multiplies two vectors (Hadamard product).
-
auto operator*(const vector& v,
const scalar_
type& s) -> vector constexpr noexcept - Componentwise-multiplies a vector by a scalar.
- auto operator+(const vector& v1, const vector& v2) -> vector constexpr noexcept
- Componentwise-adds two vectors.
- auto operator-(const vector& v1, const vector& v2) -> vector constexpr noexcept
- Componentwise-subtracts one vector from another.
- auto operator/(const vector& v1, const vector& v2) -> vector constexpr noexcept
- Componentwise-divides one vector by another.
-
auto operator/(const vector& v,
const scalar_
type& s) -> vector constexpr noexcept - Componentwise-divides a vector by a scalar.
Function documentation
template<typename Scalar, size_t Dimensions>
stim:: vector<Scalar, Dimensions>:: vector(scalar_ type x,
scalar_ type y) constexpr noexcept
Componentwise constructor.
template<typename Scalar, size_t Dimensions>
stim:: vector<Scalar, Dimensions>:: vector(scalar_ type x,
scalar_ type y,
scalar_ type z = scalar_ type{}) constexpr noexcept
Componentwise constructor.
template<typename Scalar, size_t Dimensions>
stim:: vector<Scalar, Dimensions>:: vector(scalar_ type x,
scalar_ type y,
scalar_ type z = scalar_ type{},
scalar_ type w = scalar_ type{}) constexpr noexcept
Componentwise constructor.
template<typename Scalar, size_t Dimensions>
stim:: vector<Scalar, Dimensions>:: vector(scalar_ type broadcast) explicit constexpr noexcept
Broadcast constructor.
Initializes all the scalar components of the vector to the same value.
template<typename Scalar, size_t Dimensions>
stim:: vector<Scalar, Dimensions>:: operator::FVector() const noexcept
Converts a 3D vector into a UE4 FVector.
template<typename Scalar, size_t Dimensions>
stim:: vector<Scalar, Dimensions>:: operator::FVector2D() const noexcept
Converts a 2D vector into a UE4 FVector2D.
template<typename Scalar, size_t Dimensions>
stim:: vector<Scalar, Dimensions>:: operator::FVector4() const noexcept
Converts a 4D vector into a UE4 FVector4.
template<typename Scalar, size_t Dimensions>
stim:: vector<Scalar, Dimensions>:: vector(const ::FVector2D& vec) noexcept
Constructs a 2D vector from a UE4 FVector2D.
template<typename Scalar, size_t Dimensions>
stim:: vector<Scalar, Dimensions>:: vector(const ::FVector4& vec) noexcept
Constructs a 4D vector from a UE4 FVector4.