jaulib v1.3.8
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
vec3f.hpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright Gothel Software e.K.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * This Source Code Form is subject to the terms of the MIT License
8 * If a copy of the MIT was not distributed with this file,
9 * you can obtain one at https://opensource.org/license/mit/.
10 */
11
12#ifndef JAU_MATH_VEC3F_HPP_
13#define JAU_MATH_VEC3F_HPP_
14
15#include <cmath>
16#include <cstdarg>
17#include <cassert>
18#include <limits>
19#include <string>
20#include <algorithm>
21
22#include <jau/float_math.hpp>
23
24#include <initializer_list>
25#include <iostream>
26
27#include <jau/math/vec2f.hpp>
28
29namespace jau::math {
30
31 /** \addtogroup Math
32 *
33 * @{
34 */
35
36 /**
37 * 3D vector using three value_type components.
38 *
39 * Component and overall alignment is natural as sizeof(value_type),
40 * i.e. sizeof(value_type) == alignof(value_type)
41 */
42 template <typename Value_type,
43 std::enable_if_t<std::is_floating_point_v<Value_type> &&
44 sizeof(Value_type) == alignof(Value_type), bool> = true>
45 class alignas(sizeof(Value_type)) Vector3F {
46 public:
49 typedef const value_type* const_pointer;
53 typedef const value_type* const_iterator;
54
55 /** value alignment is sizeof(value_type) */
56 constexpr static int value_alignment = sizeof(value_type);
57
58 /** Number of value_type components */
59 constexpr static const size_t components = 3;
60
61 /** Size in bytes with value_alignment */
62 constexpr static const size_t byte_size = components * sizeof(value_type);
63
65
66 constexpr static const value_type zero = value_type(0);
67 constexpr static const value_type one = value_type(1);
68
72
73 constexpr Vector3F() noexcept
74 : x(zero), y(zero), z(zero) {}
75
76 constexpr Vector3F(const value_type v) noexcept
77 : x(v), y(v), z(v) {}
78
79 constexpr Vector3F(const value_type x_, const value_type y_, const value_type z_) noexcept
80 : x(x_), y(y_), z(z_) {}
81
82 constexpr Vector3F(const Vec2& o2, const value_type z_) noexcept
83 : x(o2.x), y(o2.y), z(z_) {}
84
85 constexpr Vector3F(const_iterator v) noexcept
86 : x(v[0]), y(v[1]), z(v[2]) {}
87
88 constexpr Vector3F(std::initializer_list<value_type> v) noexcept
89 : x(v[0]), y(v[1]), z(v[2]) {}
90
91 constexpr Vector3F(const Vector3F& o) noexcept = default;
92 constexpr Vector3F(Vector3F&& o) noexcept = default;
93 constexpr Vector3F& operator=(const Vector3F&) noexcept = default;
94 constexpr Vector3F& operator=(Vector3F&&) noexcept = default;
95
96 constexpr Vector3F copy() noexcept { return Vector3F(*this); }
97
98 /** Returns read-only component */
99 constexpr value_type operator[](size_t i) const noexcept {
100 assert(i < 3);
101 return (&x)[i];
102 }
103
104 explicit operator const_pointer() const noexcept { return &x; }
105 constexpr const_iterator cbegin() const noexcept { return &x; }
106
107 /** Returns writeable reference to component */
108 constexpr reference operator[](size_t i) noexcept {
109 assert(i < 3);
110 return (&x)[i];
111 }
112
113 explicit operator pointer() noexcept { return &x; }
114 constexpr iterator begin() noexcept { return &x; }
115
116 /** xyz = this, returns xyz. */
117 constexpr iterator get(iterator xyz) const noexcept
118 { xyz[0] = x; xyz[1] = y; xyz[2] = z; return xyz; }
119
120 constexpr bool equals(const Vector3F& o, const value_type epsilon=std::numeric_limits<value_type>::epsilon()) const noexcept {
121 if( this == &o ) {
122 return true;
123 } else {
124 return jau::equals(x, o.x, epsilon) &&
125 jau::equals(y, o.y, epsilon) &&
126 jau::equals(z, o.z, epsilon);
127 }
128 }
129 constexpr bool operator==(const Vector3F& rhs) const noexcept {
130 return equals(rhs);
131 }
132 /** TODO
133 constexpr bool operator<=>(const vec3f_t& rhs ) const noexcept {
134 return ...
135 } */
136
137 /** this = { o, z }, returns this. */
138 constexpr Vector3F& set(const Vec2f& o, const value_type z_) noexcept {
139 x = o.x;
140 y = o.y;
141 z = z_;
142 return *this;
143 }
144
145 constexpr Vector3F& set(const value_type vx, const value_type vy, const value_type vz) noexcept
146 { x=vx; y=vy; z=vz; return *this; }
147
148 /** this = xyz, returns this. */
149 constexpr Vector3F& set(const_iterator xyz) noexcept
150 { x=xyz[0]; y=xyz[1]; z=xyz[2]; return *this; }
151
152 /** this = this + {d.x, d.y, d.z}, component wise. Returns this. */
153 constexpr Vector3F& add(const Vector3F& d) noexcept
154 { x+=d.x; y+=d.y; z+=d.z; return *this; }
155
156 /** this = this + {dx, dy, dz}, component wise. Returns this. */
157 constexpr Vector3F& add(const value_type dx, const value_type dy, const value_type dz) noexcept
158 { x+=dx; y+=dy; z+=dz; return *this; }
159
160 /** this = this * {s.x, s.y, s.z}, component wise. Returns this. */
161 constexpr Vector3F& mul(const Vector3F& s) noexcept
162 { x*=s.x; y*=s.y; z*=s.z; return *this; }
163
164 /** this = this * {sx, sy, sz}, component wise. Returns this. */
165 constexpr Vector3F& mul(const value_type sx, const value_type sy, const value_type sz) noexcept
166 { x*=sx; y*=sy; z*=sz; return *this; }
167
168 /** this = this * s, component wise. Returns this. */
169 constexpr Vector3F& scale(const value_type s) noexcept
170 { x*=s; y*=s; z*=s; return *this; }
171
172 /** this = this + rhs, component wise. Returns this. */
173 constexpr Vector3F& operator+=(const Vector3F& rhs) noexcept {
174 x+=rhs.x; y+=rhs.y; z+=rhs.z;
175 return *this;
176 }
177
178 /** this = this - rhs, component wise. Returns this. */
179 constexpr Vector3F& operator-=(const Vector3F& rhs) noexcept {
180 x-=rhs.x; y-=rhs.y; z-=rhs.z;
181 return *this;
182 }
183
184 /**
185 * this = this * {s.x, s.y, s.z}, component wise.
186 * @param s scale factor
187 * @return this instance
188 */
189 constexpr Vector3F& operator*=(const Vector3F& s) noexcept {
190 x*=s.x; y*=s.y; z*=s.z;
191 return *this;
192 }
193 /**
194 * this = this / {s.x, s.y, s.z}, component wise.
195 * @param s scale factor
196 * @return this instance
197 */
198 constexpr Vector3F& operator/=(const Vector3F& s) noexcept {
199 x/=s.x; y/=s.y; z/=s.z;
200 return *this;
201 }
202
203 /**
204 * this = this * s, component wise.
205 * @param s scale factor
206 * @return this instance
207 */
208 constexpr Vector3F& operator*=(const value_type s) noexcept {
209 x*=s; y*=s; z*=s;
210 return *this;
211 }
212
213 /**
214 * this = this / s, component wise.
215 * @param s scale factor
216 * @return this instance
217 */
218 constexpr Vector3F& operator/=(const value_type s) noexcept {
219 x/=s; y/=s; z/=s;
220 return *this;
221 }
222
223 /** Rotates this vector around the Z-axis in place, returns *this */
224 constexpr_cxx26 Vector3F& rotateZ(const value_type radians) noexcept {
225 return rotateZ(std::sin(radians), std::cos(radians));
226 }
227
228 /** Rotates this vector in place, returns *this */
229 constexpr Vector3F& rotateZ(const value_type sin, const value_type cos) noexcept {
230 const value_type x0 = x;
231 x = x0 * cos - y * sin;
232 y = x0 * sin + y * cos;
233 return *this;
234 }
235
236 std::string toString() const noexcept { return std::to_string(x)+", "+std::to_string(y)+", "+std::to_string(z); }
237
238 constexpr bool is_zero() const noexcept {
239 return jau::is_zero(x) && jau::is_zero(y) && jau::is_zero(z);
240 }
241
242 /**
243 * Return the squared length of a vector, a.k.a the squared <i>norm</i> or squared <i>magnitude</i>
244 */
245 constexpr value_type length_sq() const noexcept {
246 return x*x + y*y + z*z;
247 }
248
249 /**
250 * Return the length of a vector, a.k.a the <i>norm</i> or <i>magnitude</i>
251 */
252 constexpr value_type length() const noexcept {
253 return std::sqrt(length_sq());
254 }
255
256 /**
257 * Normalize this vector in place
258 */
259 constexpr Vector3F& normalize() noexcept {
260 const value_type lengthSq = length_sq();
261 if ( jau::is_zero( lengthSq ) ) {
262 x = zero;
263 y = zero;
264 z = zero;
265 } else {
266 const value_type invSqr = one / std::sqrt(lengthSq);
267 x *= invSqr;
268 y *= invSqr;
269 z *= invSqr;
270 }
271 return *this;
272 }
273
274 /**
275 * Return the squared distance between this vector and the given one.
276 * <p>
277 * When comparing the relative distance between two points it is usually sufficient to compare the squared
278 * distances, thus avoiding an expensive square root operation.
279 * </p>
280 */
281 constexpr value_type dist_sq(const Vector3F& o) const noexcept {
282 const value_type dx = x - o.x;
283 const value_type dy = y - o.y;
284 const value_type dz = z - o.z;
285 return dx*dx + dy*dy + dz*dz;
286 }
287
288 /**
289 * Return the distance between this vector and the given one.
290 */
291 constexpr value_type dist(const Vector3F& o) const noexcept {
292 return std::sqrt(dist_sq(o));
293 }
294
295 /**
296 * Return the dot product of this vector and the given one
297 * @return the dot product as value_type
298 */
299 constexpr value_type dot(const Vector3F& o) const noexcept {
300 return x*o.x + y*o.y + z*o.z;
301 }
302
303 /**
304 * cross product this x b
305 * @return new resulting vector
306 */
307 constexpr Vector3F cross(const Vector3F& b) const noexcept {
308 return Vector3F( y * b.z - z * b.y,
309 z * b.x - x * b.z,
310 x * b.y - y * b.x);
311 }
312
313 /**
314 * cross product this = a x b, with a, b different from this
315 * @return this for chaining
316 */
317 constexpr Vector3F& cross(const Vector3F& a, const Vector3F& b) noexcept {
318 x = a.y * b.z - a.z * b.y;
319 y = a.z * b.x - a.x * b.z;
320 z = a.x * b.y - a.y * b.x;
321 return *this;
322 }
323
324 /**
325 * Return the cosines of the angle between to vectors
326 * @param vec1 vector 1
327 * @param vec2 vector 2
328 */
329 constexpr value_type cos_angle(const Vector3F& o) const noexcept {
330 return dot(o) / ( length() * o.length() ) ;
331 }
332
333 /**
334 * Return the angle between to vectors in radians
335 * @param vec1 vector 1
336 * @param vec2 vector 2
337 */
338 constexpr_cxx26 value_type angle(const Vector3F& o) const noexcept {
339 return std::acos( cos_angle(o) );
340 }
341
342 constexpr_cxx23 bool intersects(const Vector3F& o) const noexcept {
343 const value_type eps = std::numeric_limits<value_type>::epsilon();
344 if( std::abs(x-o.x) >= eps || std::abs(y-o.y) >= eps || std::abs(z-o.z) >= eps ) {
345 return false;
346 }
347 return true;
348 }
349 };
350
351 template<typename T,
352 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
353 constexpr Vector3F<T> operator+(const Vector3F<T>& lhs, const Vector3F<T>& rhs ) noexcept {
354 // Returning a Vector3 object from the returned reference of operator+=()
355 // may hinder copy-elision or "named return value optimization" (NRVO).
356 // return Vector3<T>(lhs) += rhs;
357
358 // Returning named object allows copy-elision (NRVO),
359 // only one object is created 'on target'.
360 Vector3F<T> r(lhs); r += rhs; return r;
361 }
362
363 template<typename T,
364 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
365 constexpr Vector3F<T> operator-(const Vector3F<T>& lhs, const Vector3F<T>& rhs ) noexcept {
366 Vector3F<T> r(lhs); r -= rhs; return r;
367 }
368
369 template<typename T,
370 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
371 constexpr Vector3F<T> operator-(const Vector3F<T>& lhs) noexcept {
372 Vector3F<T> r(lhs);
373 r *= -1;
374 return r;
375 }
376
377 template<typename T,
378 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
379 constexpr Vector3F<T> operator*(const Vector3F<T>& lhs, const T s ) noexcept {
380 Vector3F<T> r(lhs); r *= s; return r;
381 }
382
383 template<typename T,
384 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
385 constexpr Vector3F<T> operator*(const T s, const Vector3F<T>& rhs) noexcept {
386 Vector3F<T> r(rhs); r *= s; return r;
387 }
388
389 template<typename T,
390 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
391 constexpr Vector3F<T> operator/(const Vector3F<T>& lhs, const T s ) noexcept {
392 Vector3F<T> r(lhs); r /= s; return r;
393 }
394
395 template<typename T,
396 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
397 constexpr Vector3F<T> operator/(const T s, const Vector3F<T>& rhs) noexcept {
398 Vector3F<T> r(rhs);
399 r.x=s/r.x; r.y=s/r.y; r.z=s/r.z;
400 return r;
401 }
402
403 template<typename T,
404 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
405 constexpr Vector3F<T> min(const Vector3F<T>& lhs, const Vector3F<T>& rhs) noexcept {
406 return Vector3F<T>(std::min(lhs.x, rhs.x), std::min(lhs.y, rhs.y), std::min(lhs.z, rhs.z));
407 }
408
409 template<typename T,
410 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
411 constexpr Vector3F<T> max(const Vector3F<T>& lhs, const Vector3F<T>& rhs) noexcept {
412 return Vector3F<T>(std::max(lhs.x, rhs.x), std::max(lhs.y, rhs.y), std::max(lhs.z, rhs.z));
413 }
414
415 template<typename T,
416 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
417 constexpr Vector3F<T> abs(const Vector3F<T>& lhs) noexcept {
418 return Vector3F<T>(std::abs(lhs.x), std::abs(lhs.y), std::abs(lhs.z));
419 }
420
421 template<typename T,
422 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
423 std::ostream& operator<<(std::ostream& out, const Vector3F<T>& v) noexcept {
424 return out << v.toString();
425 }
426
427 static_assert(3 == Vector3F<double>::components);
428 static_assert(sizeof(double) == Vector3F<double>::value_alignment);
429 static_assert(sizeof(double) == alignof(Vector3F<double>));
430 static_assert(sizeof(double)*3 == Vector3F<double>::byte_size);
431 static_assert(sizeof(double)*3 == sizeof(Vector3F<double>));
432
434 static_assert(3 == Vec3f::components);
435 static_assert(sizeof(float) == Vec3f::value_alignment);
436 static_assert(sizeof(float) == alignof(Vec3f));
437 static_assert(sizeof(float)*3 == Vec3f::byte_size);
438 static_assert(sizeof(float)*3 == sizeof(Vec3f));
439
440 /**
441 * Point3F alias of Vector3F
442 */
443 template<typename Value_type,
444 std::enable_if_t<std::is_floating_point_v<Value_type> &&
445 sizeof(Value_type) == alignof(Value_type), bool> = true>
447
449 static_assert(3 == Point3f::components);
450 static_assert(sizeof(float) == Point3f::value_alignment);
451 static_assert(sizeof(float) == alignof(Point3f));
452 static_assert(sizeof(float)*3 == Point3f::byte_size);
453 static_assert(sizeof(float)*3 == sizeof(Point3f));
454
455 /**
456 * Simple compound denoting a ray.
457 *
458 * Component and overall alignment is as sizeof(value_type), i.e. packed.
459 *
460 * A ray, also known as a half line, consists out of it's <i>origin</i>
461 * and <i>direction</i>. Hence it is bound to only the <i>origin</i> side,
462 * where the other end is +infinitive.
463 * <pre>
464 * R(t) = R0 + Rd * t with R0 origin, Rd direction and t > 0.0
465 * </pre>
466 */
467 template<typename Value_type,
468 std::enable_if_t<std::is_floating_point_v<Value_type>, bool> = true>
469 class alignas(sizeof(Value_type)) Ray3F {
470 public:
473 typedef const value_type* const_pointer;
474
475 /** value alignment is sizeof(value_type) */
476 constexpr static int value_alignment = sizeof(value_type);
477
478 /** Number of value_type components */
479 constexpr static const size_t components = 6;
480
481 /** Size in bytes with value_alignment */
482 constexpr static const size_t byte_size = components * sizeof(value_type);
483
484 /** Origin of Ray. */
486
487 /** Normalized direction vector of ray. */
489
490 std::string toString() const noexcept { return "Ray[orig "+orig.toString()+", dir "+dir.toString() +"]"; }
491 };
492
493 template<typename T,
494 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
495 std::ostream& operator<<(std::ostream& out, const Ray3F<T>& v) noexcept {
496 return out << v.toString();
497 }
498
500 static_assert(6 == Ray3f::components);
501 static_assert(sizeof(float) == Ray3f::value_alignment);
502 static_assert(sizeof(float) == alignof(Ray3f));
503 static_assert(sizeof(float)*6 == Ray3f::byte_size);
504 static_assert(sizeof(float)*6 == sizeof(Ray3f));
505
506 /**@}*/
507
508} // namespace jau::math
509
510#endif /* JAU_MATH_VEC3F_HPP_ */
Simple compound denoting a ray.
Definition vec3f.hpp:469
std::string toString() const noexcept
Definition vec3f.hpp:490
2D vector using two value_type components.
Definition vec2f.hpp:41
3D vector using three value_type components.
Definition vec3f.hpp:45
constexpr Vector3F(const value_type v) noexcept
Definition vec3f.hpp:76
constexpr Vector3F & operator*=(const Vector3F &s) noexcept
this = this * {s.x, s.y, s.z}, component wise.
Definition vec3f.hpp:189
constexpr reference operator[](size_t i) noexcept
Returns writeable reference to component.
Definition vec3f.hpp:108
constexpr Vector3F & cross(const Vector3F &a, const Vector3F &b) noexcept
cross product this = a x b, with a, b different from this
Definition vec3f.hpp:317
constexpr Vector3F() noexcept
Definition vec3f.hpp:73
constexpr_cxx26 Vector3F & rotateZ(const value_type radians) noexcept
Rotates this vector around the Z-axis in place, returns *this.
Definition vec3f.hpp:224
constexpr Vector3F & set(const Vec2f &o, const value_type z_) noexcept
TODO constexpr bool operator<=>(const vec3f_t& rhs ) const noexcept { return ... }...
Definition vec3f.hpp:138
constexpr bool operator==(const Vector3F &rhs) const noexcept
Definition vec3f.hpp:129
constexpr Vector3F & operator/=(const value_type s) noexcept
this = this / s, component wise.
Definition vec3f.hpp:218
constexpr_cxx26 value_type angle(const Vector3F &o) const noexcept
Return the angle between to vectors in radians.
Definition vec3f.hpp:338
constexpr Vector3F & operator=(const Vector3F &) noexcept=default
constexpr value_type cos_angle(const Vector3F &o) const noexcept
Return the cosines of the angle between to vectors.
Definition vec3f.hpp:329
constexpr Vector3F & normalize() noexcept
Normalize this vector in place.
Definition vec3f.hpp:259
constexpr Vector3F & operator=(Vector3F &&) noexcept=default
Vector2F< value_type, std::is_floating_point_v< value_type > > Vec2
Definition vec3f.hpp:64
constexpr value_type operator[](size_t i) const noexcept
Returns read-only component.
Definition vec3f.hpp:99
constexpr Vector3F(const_iterator v) noexcept
Definition vec3f.hpp:85
constexpr Vector3F & operator-=(const Vector3F &rhs) noexcept
this = this - rhs, component wise.
Definition vec3f.hpp:179
constexpr_cxx23 bool intersects(const Vector3F &o) const noexcept
Definition vec3f.hpp:342
constexpr iterator get(iterator xyz) const noexcept
xyz = this, returns xyz.
Definition vec3f.hpp:117
constexpr Vector3F & set(const value_type vx, const value_type vy, const value_type vz) noexcept
Definition vec3f.hpp:145
constexpr value_type length() const noexcept
Return the length of a vector, a.k.a the norm or magnitude
Definition vec3f.hpp:252
constexpr Vector3F & scale(const value_type s) noexcept
this = this * s, component wise.
Definition vec3f.hpp:169
constexpr value_type dist(const Vector3F &o) const noexcept
Return the distance between this vector and the given one.
Definition vec3f.hpp:291
constexpr Vector3F & mul(const value_type sx, const value_type sy, const value_type sz) noexcept
this = this * {sx, sy, sz}, component wise.
Definition vec3f.hpp:165
constexpr Vector3F & rotateZ(const value_type sin, const value_type cos) noexcept
Rotates this vector in place, returns *this.
Definition vec3f.hpp:229
constexpr Vector3F & operator+=(const Vector3F &rhs) noexcept
this = this + rhs, component wise.
Definition vec3f.hpp:173
constexpr Vector3F & mul(const Vector3F &s) noexcept
this = this * {s.x, s.y, s.z}, component wise.
Definition vec3f.hpp:161
constexpr value_type dist_sq(const Vector3F &o) const noexcept
Return the squared distance between this vector and the given one.
Definition vec3f.hpp:281
constexpr Vector3F(std::initializer_list< value_type > v) noexcept
Definition vec3f.hpp:88
constexpr Vector3F(const Vec2 &o2, const value_type z_) noexcept
Definition vec3f.hpp:82
constexpr Vector3F & add(const value_type dx, const value_type dy, const value_type dz) noexcept
this = this + {dx, dy, dz}, component wise.
Definition vec3f.hpp:157
constexpr const_iterator cbegin() const noexcept
Definition vec3f.hpp:105
constexpr bool is_zero() const noexcept
Definition vec3f.hpp:238
constexpr value_type dot(const Vector3F &o) const noexcept
Return the dot product of this vector and the given one.
Definition vec3f.hpp:299
constexpr value_type length_sq() const noexcept
Return the squared length of a vector, a.k.a the squared norm or squared magnitude
Definition vec3f.hpp:245
constexpr Vector3F(const Vector3F &o) noexcept=default
constexpr Vector3F cross(const Vector3F &b) const noexcept
cross product this x b
Definition vec3f.hpp:307
constexpr Vector3F & set(const_iterator xyz) noexcept
this = xyz, returns this.
Definition vec3f.hpp:149
constexpr Vector3F(const value_type x_, const value_type y_, const value_type z_) noexcept
Definition vec3f.hpp:79
constexpr Vector3F & operator*=(const value_type s) noexcept
this = this * s, component wise.
Definition vec3f.hpp:208
constexpr Vector3F & operator/=(const Vector3F &s) noexcept
this = this / {s.x, s.y, s.z}, component wise.
Definition vec3f.hpp:198
constexpr Vector3F(Vector3F &&o) noexcept=default
constexpr iterator begin() noexcept
Definition vec3f.hpp:114
std::string toString() const noexcept
Definition vec3f.hpp:236
constexpr bool equals(const Vector3F &o, const value_type epsilon=std::numeric_limits< value_type >::epsilon()) const noexcept
Definition vec3f.hpp:120
constexpr Vector3F & add(const Vector3F &d) noexcept
this = this + {d.x, d.y, d.z}, component wise.
Definition vec3f.hpp:153
#define constexpr_cxx23
#define constexpr_cxx26
std::enable_if_t< std::is_floating_point_v< T >, bool > constexpr equals(const T &a, const T &b, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
Returns true if both values are equal, i.e.
std::enable_if_t< std::is_floating_point_v< T >, bool > constexpr is_zero(const T &a, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
Returns true if the given value is less than epsilon, w/ epsilon > 0.
Vector3F< Value_type > Point3F
Point3F alias of Vector3F.
Definition vec3f.hpp:446
constexpr Quaternion< T > operator-(const Quaternion< T > &lhs, const Quaternion< T > &rhs) noexcept
constexpr Vector2F< T > operator/(const Vector2F< T > &lhs, const T s) noexcept
Definition vec2f.hpp:378
constexpr Vector2F< T > max(const Vector2F< T > &lhs, const Vector2F< T > &rhs) noexcept
Definition vec2f.hpp:398
constexpr Vector2F< T > min(const Vector2F< T > &lhs, const Vector2F< T > &rhs) noexcept
Definition vec2f.hpp:392
Ray3F< float > Ray3f
Definition vec3f.hpp:499
Vector2F< float > Vec2f
Definition vec2f.hpp:416
constexpr Matrix4< T > operator*(const Matrix4< T > &lhs, const Matrix4< T > &rhs) noexcept
Definition mat4f.hpp:1906
Vector3F< float > Vec3f
Definition vec3f.hpp:433
constexpr Quaternion< T > operator+(const Quaternion< T > &lhs, const Quaternion< T > &rhs) noexcept
std::ostream & operator<<(std::ostream &out, const Matrix4< T > &v) noexcept
Definition mat4f.hpp:1924
constexpr Vector2F< T > abs(const Vector2F< T > &lhs) noexcept
Definition vec2f.hpp:404
Point3F< float > Point3f
Definition vec3f.hpp:448
uint8_t Value_type