template<class T>
Vector3 class
Three-component vector.
Template parameters | |
---|---|
T | Data type |
Contents
See Operations with matrices and vectors for brief introduction.
Base classes
-
template<std::class Vector
size_t size, class T> - Vector.
Derived classes
-
template<class T>class Color3
- Color in linear RGB color space.
Public static functions
- static auto xAxis(T length = T(1)) -> Vector3<T> constexpr
- Vector in direction of X axis (right)
- static auto yAxis(T length = T(1)) -> Vector3<T> constexpr
- Vector in direction of Y axis (up)
- static auto zAxis(T length = T(1)) -> Vector3<T> constexpr
- Vector in direction of Z axis (backward)
- static auto xScale(T scale) -> Vector3<T> constexpr
- Scaling vector in direction of X axis (width)
- static auto yScale(T scale) -> Vector3<T> constexpr
- Scaling vector in direction of Y axis (height)
- static auto zScale(T scale) -> Vector3<T> constexpr
- Scaling vector in direction of Z axis (depth)
Constructors, destructors, conversion operators
- Vector3(ZeroInitT = ZeroInit) constexpr noexcept
- Default constructor.
- Vector3(NoInitT) explicit noexcept
- Construct vector without initializing the contents.
- Vector3(T value) explicit constexpr noexcept
- Construct vector with one value for all components.
- Vector3(T x, T y, T z) constexpr noexcept
- Constructor.
- Vector3(const Vector2<T>& xy, T z) constexpr noexcept
- Constructor.
-
template<class U>Vector3(const Vector<3, U>& other) explicit constexpr noexcept
- Construct vector from another of different type.
-
template<class U, class V = decltype(Implementation::VectorConverter<3, T, U>::from(std::Vector3(const U& other) explicit constexpr
declval<U>()))> - Construct vector from external representation.
- Vector3(const Vector<3, 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 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 xy() -> Vector2<T>&
- XY part of the vector.
- auto xy() const -> const Vector2<T> constexpr
Function documentation
template<class T>
static Vector3<T> Magnum:: Math:: Vector3<T>:: xAxis(T length = T(1)) constexpr
Vector in direction of X axis (right)
Usable for translation or rotation along given axis, for example:
Matrix4::translation(Vector3::xAxis(5.0f)); // same as Matrix4::translation({5.0f, 0.0f, 0.0f}); Matrix4::rotation(30.0_degf, Vector3::xAxis()); // same as Matrix::rotation(30.0_degf, {1.0f, 0.0f, 0.0f});
template<class T>
Magnum:: Math:: Vector3<T>:: Vector3(T x,
T y,
T z) constexpr noexcept
Constructor.
template<class T>
template<class U>
Magnum:: Math:: Vector3<T>:: Vector3(const Vector<3, 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:: Vector3<T>:: x()
X component.
template<class T>
T Magnum:: Math:: Vector3<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:: Vector3<T>:: y()
Y component.
template<class T>
T Magnum:: Math:: Vector3<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:: Vector3<T>:: z()
Z component.
template<class T>
T Magnum:: Math:: Vector3<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:: Vector3<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:: Vector3<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:: Vector3<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.