vec2.ixx File
2D vector type and utility functions. More...
Included Headers
#include <cassert>
#include <cmath>
#include <memory>
#include <helios.math.traits.FloatingPointType>
#include <helios.math.utils>
#include <helios.math.concepts>
Namespaces Index
| namespace | helios |
| namespace | math |
|
Mathematical operations and types. More... | |
Classes Index
| struct | vec2<T> |
|
Represents a 2-dimensional vector of the generic type <T>. More... | |
Description
2D vector type and utility functions.
File Listing
The file content with the documentation metadata removed is:
18export namespace helios::math {
21 struct vec3;
62 constexpr helios::math::vec3<T> toVec3() const {
63 return helios::math::vec3<T>{v[0], v[1], static_cast<T>(0)};
74 constexpr const T& operator[](const size_t i) const noexcept {
87 constexpr T& operator[](const size_t i) noexcept {
97 inline FloatingPointType<T> length() const noexcept {
99 return static_cast<FloatingPointType<T>>(0);
113 constexpr bool isNormalized() const noexcept {
115 static_cast<FloatingPointType<T>>(v[0]) * static_cast<FloatingPointType<T>>(v[0]) +
116 static_cast<FloatingPointType<T>>(v[1]) * static_cast<FloatingPointType<T>>(v[1]);
118 return std::abs(lenSquared - static_cast<FloatingPointType<T>>(1.0)) <= helios::math::EPSILON_LENGTH;
126 inline vec2<FloatingPointType<T>> normalize() const noexcept {
128 return vec2<FloatingPointType<T>>(
129 static_cast<FloatingPointType<T>>(0),
130 static_cast<FloatingPointType<T>>(0)
133 return vec2<FloatingPointType<T>>(
134 static_cast<FloatingPointType<T>>(v[0]) / length(),
135 static_cast<FloatingPointType<T>>(v[1]) / length()
147 constexpr bool operator==(const vec2<T>& rgt) const {
158 * @param epsilon The epsilon value to use for comparison. If omitted, the default epsilon (0.0001) is used.
189 return vec2<T>{v[0] * n, v[1] * n};
207 using vec2f = vec2<float>;
208 using vec2d = vec2<double>;
210 using vec2ui = vec2<unsigned int>;
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.