template<class T>
Vector2 class
Two-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.
Public static functions
- static auto xAxis(T length = T(1)) -> Vector2<T> constexpr
- Vector in direction of X axis (right)
- static auto yAxis(T length = T(1)) -> Vector2<T> constexpr
- Vector in direction of Y axis (up)
- static auto xScale(T scale) -> Vector2<T> constexpr
- Scaling vector in direction of X axis (width)
- static auto yScale(T scale) -> Vector2<T> constexpr
- Scaling vector in direction of Y axis (height)
Constructors, destructors, conversion operators
- Vector2(ZeroInitT = ZeroInit) constexpr noexcept
- Default constructor.
- Vector2(NoInitT) explicit noexcept
- Construct vector without initializing the contents.
- Vector2(T value) explicit constexpr noexcept
- Construct vector with one value for all components.
- Vector2(T x, T y) constexpr noexcept
- Constructor.
-
template<class U>Vector2(const Vector<2, U>& other) explicit constexpr noexcept
- Construct vector from another of different type.
-
template<class U, class V = decltype(Implementation::VectorConverter<2, T, U>::from(std::Vector2(const U& other) explicit constexpr
declval<U>()))> - Construct vector from external representation.
- Vector2(const Vector<2, 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 perpendicular() const -> Vector2<T>
- Perpendicular vector.
- auto aspectRatio() const -> T
- Aspect ratio.
Function documentation
template<class T>
Magnum:: Math:: Vector2<T>:: Vector2(T x,
T y) constexpr noexcept
Constructor.
template<class T>
template<class U>
Magnum:: Math:: Vector2<T>:: Vector2(const Vector<2, 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:: Vector2<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:: Vector2<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>
Vector2<T> Magnum:: Math:: Vector2<T>:: perpendicular() const
Perpendicular vector.
Returns vector rotated 90° counterclockwise.
template<class T>
T Magnum:: Math:: Vector2<T>:: aspectRatio() const
Aspect ratio.
Returns quotient of the two elements.