vec2.ixx File
2D vector type and utility functions. More...
Included Headers
#include <cassert>
#include <cmath>
#include <memory>
#include <cstddef>
#include <helios.math.utils>
#include <helios.math.traits.FloatingPointType>
#include <helios.math.concepts>
Namespaces Index
| namespace | helios |
| namespace | math |
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:
19export namespace helios::math {
44 using Numeric_type = T;
65 constexpr helios::math::vec3<T> toVec3() const {
66 return helios::math::vec3<T>{v[0], v[1], static_cast<T>(0)};
77 constexpr const T& operator[](const size_t i) const noexcept {
90 constexpr T& operator[](const size_t i) noexcept {
100 inline FloatingPointType<T> length() const noexcept {
102 return static_cast<FloatingPointType<T>>(0);
116 constexpr bool isNormalized() const noexcept {
118 static_cast<FloatingPointType<T>>(v[0]) * static_cast<FloatingPointType<T>>(v[0]) +
119 static_cast<FloatingPointType<T>>(v[1]) * static_cast<FloatingPointType<T>>(v[1]);
121 return std::abs(lenSquared - static_cast<FloatingPointType<T>>(1.0)) <= helios::math::EPSILON_LENGTH;
129 inline vec2<FloatingPointType<T>> normalize() const noexcept {
131 return vec2<FloatingPointType<T>>(
132 static_cast<FloatingPointType<T>>(0),
133 static_cast<FloatingPointType<T>>(0)
136 return vec2<FloatingPointType<T>>(
137 static_cast<FloatingPointType<T>>(v[0]) / length(),
138 static_cast<FloatingPointType<T>>(v[1]) / length()
150 constexpr bool operator==(const vec2<T>& rgt) const {
171 constexpr bool same(const vec2<T>& rgt, T epsilon = 0.0001) const requires std::is_floating_point_v<T> {
199 return vec2<T>{v[0] * n, v[1] * n};
217 using vec2f = vec2<float>;
218 using vec2d = vec2<double>;
220 using vec2ui = vec2<unsigned int>;
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.