template<class T>
Magnum::Math::Vector4 class

Four-component vector.

Template parameters
T Data type

See Operations with matrices and vectors for brief introduction.

Base classes

template<std::size_t size, class T>
class Vector
Vector.

Derived classes

template<class T = Float>
class Color4
Color in linear RGBA color space.

Public static functions

template<std::size_t otherSize>
static auto pad(const Vector<otherSize, T>& a, T xyz, T w) -> Vector4<T> constexpr
Pad vector to four-component one.

Constructors, destructors, conversion operators

Vector4(ZeroInitT = ZeroInit) constexpr noexcept
Default constructor.

Vector4(NoInitT) explicit noexcept
Construct vector without initializing the contents.

Vector4(T value) explicit constexpr noexcept
Construct vector with one value for all components.
Vector4(T x, T y, T z, T w) constexpr noexcept
Constructor.
Vector4(const Vector3<T>& xyz, T w) constexpr noexcept
Constructor.
template<class U>
Vector4(const Vector<4, U>& other) explicit constexpr noexcept
Construct vector from another of different type.
template<class U, class V = decltype(Implementation::VectorConverter<4, T, U>::from(std::declval<U>()))>
Vector4(const U& other) explicit constexpr
Construct vector from external representation.
Vector4(const Vector<4, T>& other) constexpr noexcept
Copy constructor.

Public functions

auto x() -> T&
X component.
auto x() const -> T constexpr
auto y() -> T&
Y component.
auto y() const -> T constexpr
auto z() -> T&
Z component.
auto z() const -> T constexpr
auto w() -> T&
W component.
auto w() const -> T constexpr
auto r() -> T&
R component.
auto r() const -> T constexpr
auto g() -> T&
G component.
auto g() const -> T constexpr
auto b() -> T&
B component.
auto b() const -> T constexpr
auto a() -> T&
A component.
auto a() const -> T constexpr
auto xyz() -> Vector3<T>&
XYZ part of the vector.
auto xyz() const -> const Vector3<T> constexpr
auto rgb() -> Vector3<T>&
RGB part of the vector.
auto rgb() const -> const Vector3<T> constexpr
auto xy() -> Vector2<T>&
XY part of the vector.
auto xy() const -> const Vector2<T> constexpr

Function documentation

template<class T> template<std::size_t otherSize>
static Vector4<T> Magnum::Math::Vector4<T>::pad(const Vector<otherSize, T>& a, T xyz, T w) constexpr

Pad vector to four-component one.

If size of a is smaller than 4, it is padded from right with xyz for first three component and w for fourth component, otherwise it's cut.

template<class T>
Magnum::Math::Vector4<T>::Vector4(ZeroInitT = ZeroInit) constexpr noexcept

Default constructor.

\[ \boldsymbol v = \boldsymbol 0 \]

template<class T>
Magnum::Math::Vector4<T>::Vector4(T x, T y, T z, T w) constexpr noexcept

Constructor.

\[ \boldsymbol v = \begin{pmatrix} x \\ y \\ z \\ w \end{pmatrix} \]

template<class T>
Magnum::Math::Vector4<T>::Vector4(const Vector3<T>& xyz, T w) constexpr noexcept

Constructor.

\[ \boldsymbol v = \begin{pmatrix} v_x \\ v_y \\ v_z \\ w \end{pmatrix} \]

template<class T> template<class U>
Magnum::Math::Vector4<T>::Vector4(const Vector<4, U>& other) explicit constexpr noexcept

Construct vector from another of different type.

Performs only default casting on the values, no rounding or anything else. Example usage:

Vector<4, Float> floatingPoint(1.3f, 2.7f, -15.0f, 7.0f);
Vector<4, Byte> integral(floatingPoint);
// integral == {1, 2, -15, 7}

template<class T>
T& Magnum::Math::Vector4<T>::x()

X component.

template<class T>
T Magnum::Math::Vector4<T>::x() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T& Magnum::Math::Vector4<T>::y()

Y component.

template<class T>
T Magnum::Math::Vector4<T>::y() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T& Magnum::Math::Vector4<T>::z()

Z component.

template<class T>
T Magnum::Math::Vector4<T>::z() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T& Magnum::Math::Vector4<T>::w()

W component.

template<class T>
T Magnum::Math::Vector4<T>::w() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T& Magnum::Math::Vector4<T>::r()

R component.

Equivalent to x().

template<class T>
T Magnum::Math::Vector4<T>::r() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T& Magnum::Math::Vector4<T>::g()

G component.

Equivalent to y().

template<class T>
T Magnum::Math::Vector4<T>::g() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T& Magnum::Math::Vector4<T>::b()

B component.

Equivalent to z().

template<class T>
T Magnum::Math::Vector4<T>::b() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T& Magnum::Math::Vector4<T>::a()

A component.

Equivalent to w().

template<class T>
T Magnum::Math::Vector4<T>::a() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Vector3<T>& Magnum::Math::Vector4<T>::xyz()

XYZ part of the vector.

Returns First three components of the vector

template<class T>
const Vector3<T> Magnum::Math::Vector4<T>::xyz() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Vector3<T>& Magnum::Math::Vector4<T>::rgb()

RGB part of the vector.

Returns First three components of the vector

Equivalent to xyz().

template<class T>
const Vector3<T> Magnum::Math::Vector4<T>::rgb() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Vector2<T>& Magnum::Math::Vector4<T>::xy()

XY part of the vector.

Returns First two components of the vector

template<class T>
const Vector2<T> Magnum::Math::Vector4<T>::xy() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.