Gamp v0.0.7-36-g24b1eb6
Gamp: Graphics, Audio, Multimedia and Processing
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 a Vec2 instance using x and y component, dropping z
99 constexpr Vec2 toVec2xy() const noexcept { return Vec2(x, y); }
100
101 /** Returns read-only component */
102 constexpr value_type operator[](size_t i) const noexcept {
103 assert(i < 3);
104 return (&x)[i];
105 }
106
107 explicit operator const_pointer() const noexcept { return &x; }
108 constexpr const_iterator cbegin() const noexcept { return &x; }
109
110 /** Returns writeable reference to component */
111 constexpr reference operator[](size_t i) noexcept {
112 assert(i < 3);
113 return (&x)[i];
114 }
115
116 explicit operator pointer() noexcept { return &x; }
117 constexpr iterator begin() noexcept { return &x; }
118
119 /** xyz = this, returns xyz. */
120 constexpr iterator get(iterator xyz) const noexcept
121 { xyz[0] = x; xyz[1] = y; xyz[2] = z; return xyz; }
122
123 constexpr bool equals(const Vector3F& o, const value_type epsilon=std::numeric_limits<value_type>::epsilon()) const noexcept {
124 if( this == &o ) {
125 return true;
126 } else {
127 return jau::equals(x, o.x, epsilon) &&
128 jau::equals(y, o.y, epsilon) &&
129 jau::equals(z, o.z, epsilon);
130 }
131 }
132 constexpr bool operator==(const Vector3F& rhs) const noexcept {
133 return equals(rhs);
134 }
135 /** TODO
136 constexpr bool operator<=>(const vec3f_t& rhs ) const noexcept {
137 return ...
138 } */
139
140 /** this = { o, z }, returns this. */
141 constexpr Vector3F& set(const Vec2f& o, const value_type z_) noexcept {
142 x = o.x;
143 y = o.y;
144 z = z_;
145 return *this;
146 }
147
148 constexpr Vector3F& set(const value_type vx, const value_type vy, const value_type vz) noexcept
149 { x=vx; y=vy; z=vz; return *this; }
150
151 /** this = xyz, returns this. */
152 constexpr Vector3F& set(const_iterator xyz) noexcept
153 { x=xyz[0]; y=xyz[1]; z=xyz[2]; return *this; }
154
155 /** this = this + {d.x, d.y, d.z}, component wise. Returns this. */
156 constexpr Vector3F& add(const Vector3F& d) noexcept
157 { x+=d.x; y+=d.y; z+=d.z; return *this; }
158
159 /** this = this + {dx, dy, dz}, component wise. Returns this. */
160 constexpr Vector3F& add(const value_type dx, const value_type dy, const value_type dz) noexcept
161 { x+=dx; y+=dy; z+=dz; return *this; }
162
163 /** this = this * {s.x, s.y, s.z}, component wise. Returns this. */
164 constexpr Vector3F& mul(const Vector3F& s) noexcept
165 { x*=s.x; y*=s.y; z*=s.z; return *this; }
166
167 /** this = this * {sx, sy, sz}, component wise. Returns this. */
168 constexpr Vector3F& mul(const value_type sx, const value_type sy, const value_type sz) noexcept
169 { x*=sx; y*=sy; z*=sz; return *this; }
170
171 /** this = this * s, component wise. Returns this. */
172 constexpr Vector3F& scale(const value_type s) noexcept
173 { x*=s; y*=s; z*=s; return *this; }
174
175 /** this = this + rhs, component wise. Returns this. */
176 constexpr Vector3F& operator+=(const Vector3F& rhs) noexcept {
177 x+=rhs.x; y+=rhs.y; z+=rhs.z;
178 return *this;
179 }
180
181 /** this = this - rhs, component wise. Returns this. */
182 constexpr Vector3F& operator-=(const Vector3F& rhs) noexcept {
183 x-=rhs.x; y-=rhs.y; z-=rhs.z;
184 return *this;
185 }
186
187 /**
188 * this = this * {s.x, s.y, s.z}, component wise.
189 * @param s scale factor
190 * @return this instance
191 */
192 constexpr Vector3F& operator*=(const Vector3F& s) noexcept {
193 x*=s.x; y*=s.y; z*=s.z;
194 return *this;
195 }
196 /**
197 * this = this / {s.x, s.y, s.z}, component wise.
198 * @param s scale factor
199 * @return this instance
200 */
201 constexpr Vector3F& operator/=(const Vector3F& s) noexcept {
202 x/=s.x; y/=s.y; z/=s.z;
203 return *this;
204 }
205
206 /**
207 * this = this * s, component wise.
208 * @param s scale factor
209 * @return this instance
210 */
211 constexpr Vector3F& operator*=(const value_type s) noexcept {
212 x*=s; y*=s; z*=s;
213 return *this;
214 }
215
216 /**
217 * this = this / s, component wise.
218 * @param s scale factor
219 * @return this instance
220 */
221 constexpr Vector3F& operator/=(const value_type s) noexcept {
222 x/=s; y/=s; z/=s;
223 return *this;
224 }
225
226 /** Rotates this vector around the Z-axis in place, returns *this */
227 constexpr_cxx26 Vector3F& rotateZ(const value_type radians) noexcept {
228 return rotateZ(std::sin(radians), std::cos(radians));
229 }
230
231 /** Rotates this vector in place, returns *this */
232 constexpr Vector3F& rotateZ(const value_type sin, const value_type cos) noexcept {
233 const value_type x0 = x;
234 x = x0 * cos - y * sin;
235 y = x0 * sin + y * cos;
236 return *this;
237 }
238
239 std::string toString() const noexcept { return std::to_string(x)+", "+std::to_string(y)+", "+std::to_string(z); }
240
241 constexpr bool is_zero() const noexcept {
242 return jau::is_zero(x) && jau::is_zero(y) && jau::is_zero(z);
243 }
244
245 /**
246 * Return the squared length of a vector, a.k.a the squared <i>norm</i> or squared <i>magnitude</i>
247 */
248 constexpr value_type length_sq() const noexcept {
249 return x*x + y*y + z*z;
250 }
251
252 /**
253 * Return the length of a vector, a.k.a the <i>norm</i> or <i>magnitude</i>
254 */
255 constexpr value_type length() const noexcept {
256 return std::sqrt(length_sq());
257 }
258
259 /**
260 * Normalize this vector in place
261 */
262 constexpr Vector3F& normalize() noexcept {
263 const value_type lengthSq = length_sq();
264 if ( jau::is_zero( lengthSq ) ) {
265 x = zero;
266 y = zero;
267 z = zero;
268 } else {
269 const value_type invSqr = one / std::sqrt(lengthSq);
270 x *= invSqr;
271 y *= invSqr;
272 z *= invSqr;
273 }
274 return *this;
275 }
276
277 /**
278 * Return the squared distance between this vector and the given one.
279 * <p>
280 * When comparing the relative distance between two points it is usually sufficient to compare the squared
281 * distances, thus avoiding an expensive square root operation.
282 * </p>
283 */
284 constexpr value_type dist_sq(const Vector3F& o) const noexcept {
285 const value_type dx = x - o.x;
286 const value_type dy = y - o.y;
287 const value_type dz = z - o.z;
288 return dx*dx + dy*dy + dz*dz;
289 }
290
291 /**
292 * Return the distance between this vector and the given one.
293 */
294 constexpr value_type dist(const Vector3F& o) const noexcept {
295 return std::sqrt(dist_sq(o));
296 }
297
298 /**
299 * Return the dot product of this vector and the given one
300 * @return the dot product as value_type
301 */
302 constexpr value_type dot(const Vector3F& o) const noexcept {
303 return x*o.x + y*o.y + z*o.z;
304 }
305
306 /**
307 * cross product this x b
308 * @return new resulting vector
309 */
310 constexpr Vector3F cross(const Vector3F& b) const noexcept {
311 return Vector3F( y * b.z - z * b.y,
312 z * b.x - x * b.z,
313 x * b.y - y * b.x);
314 }
315
316 /**
317 * cross product this = a x b, with a, b different from this
318 * @return this for chaining
319 */
320 constexpr Vector3F& cross(const Vector3F& a, const Vector3F& b) noexcept {
321 x = a.y * b.z - a.z * b.y;
322 y = a.z * b.x - a.x * b.z;
323 z = a.x * b.y - a.y * b.x;
324 return *this;
325 }
326
327 /**
328 * Return the cosines of the angle between to vectors
329 * @param vec1 vector 1
330 * @param vec2 vector 2
331 */
332 constexpr value_type cos_angle(const Vector3F& o) const noexcept {
333 return dot(o) / ( length() * o.length() ) ;
334 }
335
336 /**
337 * Return the angle between to vectors in radians
338 * @param vec1 vector 1
339 * @param vec2 vector 2
340 */
341 constexpr_cxx26 value_type angle(const Vector3F& o) const noexcept {
342 return std::acos( cos_angle(o) );
343 }
344
345 constexpr_cxx23 bool intersects(const Vector3F& o) const noexcept {
346 const value_type eps = std::numeric_limits<value_type>::epsilon();
347 if( std::abs(x-o.x) >= eps || std::abs(y-o.y) >= eps || std::abs(z-o.z) >= eps ) {
348 return false;
349 }
350 return true;
351 }
352 };
353
354 template<typename T,
355 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
356 constexpr Vector3F<T> operator+(const Vector3F<T>& lhs, const Vector3F<T>& rhs ) noexcept {
357 // Returning a Vector3 object from the returned reference of operator+=()
358 // may hinder copy-elision or "named return value optimization" (NRVO).
359 // return Vector3<T>(lhs) += rhs;
360
361 // Returning named object allows copy-elision (NRVO),
362 // only one object is created 'on target'.
363 Vector3F<T> r(lhs); r += rhs; return r;
364 }
365
366 template<typename T,
367 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
368 constexpr Vector3F<T> operator-(const Vector3F<T>& lhs, const Vector3F<T>& rhs ) noexcept {
369 Vector3F<T> r(lhs); r -= rhs; return r;
370 }
371
372 template<typename T,
373 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
374 constexpr Vector3F<T> operator-(const Vector3F<T>& lhs) noexcept {
375 Vector3F<T> r(lhs);
376 r *= -1;
377 return r;
378 }
379
380 template<typename T,
381 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
382 constexpr Vector3F<T> operator*(const Vector3F<T>& lhs, const T s ) noexcept {
383 Vector3F<T> r(lhs); r *= s; return r;
384 }
385
386 template<typename T,
387 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
388 constexpr Vector3F<T> operator*(const T s, const Vector3F<T>& rhs) noexcept {
389 Vector3F<T> r(rhs); r *= s; return r;
390 }
391
392 template<typename T,
393 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
394 constexpr Vector3F<T> operator/(const Vector3F<T>& lhs, const T s ) noexcept {
395 Vector3F<T> r(lhs); r /= s; return r;
396 }
397
398 template<typename T,
399 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
400 constexpr Vector3F<T> operator/(const T s, const Vector3F<T>& rhs) noexcept {
401 Vector3F<T> r(rhs);
402 r.x=s/r.x; r.y=s/r.y; r.z=s/r.z;
403 return r;
404 }
405
406 template<typename T,
407 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
408 constexpr Vector3F<T> min(const Vector3F<T>& lhs, const Vector3F<T>& rhs) noexcept {
409 return Vector3F<T>(std::min(lhs.x, rhs.x), std::min(lhs.y, rhs.y), std::min(lhs.z, rhs.z));
410 }
411
412 template<typename T,
413 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
414 constexpr Vector3F<T> max(const Vector3F<T>& lhs, const Vector3F<T>& rhs) noexcept {
415 return Vector3F<T>(std::max(lhs.x, rhs.x), std::max(lhs.y, rhs.y), std::max(lhs.z, rhs.z));
416 }
417
418 template<typename T,
419 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
420 constexpr Vector3F<T> abs(const Vector3F<T>& lhs) noexcept {
421 return Vector3F<T>(std::abs(lhs.x), std::abs(lhs.y), std::abs(lhs.z));
422 }
423
424 template<typename T,
425 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
426 std::ostream& operator<<(std::ostream& out, const Vector3F<T>& v) noexcept {
427 return out << v.toString();
428 }
429
430 static_assert(3 == Vector3F<double>::components);
431 static_assert(sizeof(double) == Vector3F<double>::value_alignment);
432 static_assert(sizeof(double) == alignof(Vector3F<double>));
433 static_assert(sizeof(double)*3 == Vector3F<double>::byte_size);
434 static_assert(sizeof(double)*3 == sizeof(Vector3F<double>));
435
437 static_assert(3 == Vec3f::components);
438 static_assert(sizeof(float) == Vec3f::value_alignment);
439 static_assert(sizeof(float) == alignof(Vec3f));
440 static_assert(sizeof(float)*3 == Vec3f::byte_size);
441 static_assert(sizeof(float)*3 == sizeof(Vec3f));
442
443 /**
444 * Point3F alias of Vector3F
445 */
446 template<typename Value_type,
447 std::enable_if_t<std::is_floating_point_v<Value_type> &&
448 sizeof(Value_type) == alignof(Value_type), bool> = true>
450
452 static_assert(3 == Point3f::components);
453 static_assert(sizeof(float) == Point3f::value_alignment);
454 static_assert(sizeof(float) == alignof(Point3f));
455 static_assert(sizeof(float)*3 == Point3f::byte_size);
456 static_assert(sizeof(float)*3 == sizeof(Point3f));
457
458 /**
459 * Simple compound denoting a ray.
460 *
461 * Component and overall alignment is as sizeof(value_type), i.e. packed.
462 *
463 * A ray, also known as a half line, consists out of it's <i>origin</i>
464 * and <i>direction</i>. Hence it is bound to only the <i>origin</i> side,
465 * where the other end is +infinitive.
466 * <pre>
467 * R(t) = R0 + Rd * t with R0 origin, Rd direction and t > 0.0
468 * </pre>
469 */
470 template<typename Value_type,
471 std::enable_if_t<std::is_floating_point_v<Value_type>, bool> = true>
472 class alignas(sizeof(Value_type)) Ray3F {
473 public:
476 typedef const value_type* const_pointer;
477
478 /** value alignment is sizeof(value_type) */
479 constexpr static int value_alignment = sizeof(value_type);
480
481 /** Number of value_type components */
482 constexpr static const size_t components = 6;
483
484 /** Size in bytes with value_alignment */
485 constexpr static const size_t byte_size = components * sizeof(value_type);
486
487 /** Origin of Ray. */
489
490 /** Normalized direction vector of ray. */
492
493 std::string toString() const noexcept { return "Ray[orig "+orig.toString()+", dir "+dir.toString() +"]"; }
494 };
495
496 template<typename T,
497 std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
498 std::ostream& operator<<(std::ostream& out, const Ray3F<T>& v) noexcept {
499 return out << v.toString();
500 }
501
503 static_assert(6 == Ray3f::components);
504 static_assert(sizeof(float) == Ray3f::value_alignment);
505 static_assert(sizeof(float) == alignof(Ray3f));
506 static_assert(sizeof(float)*6 == Ray3f::byte_size);
507 static_assert(sizeof(float)*6 == sizeof(Ray3f));
508
509 /**@}*/
510
511} // namespace jau::math
512
513#endif /* JAU_MATH_VEC3F_HPP_ */
Simple compound denoting a ray.
Definition vec3f.hpp:472
static constexpr const size_t byte_size
Definition vec3f.hpp:485
std::string toString() const noexcept
Definition vec3f.hpp:493
Point3F< value_type > orig
Definition vec3f.hpp:488
static constexpr const size_t components
Definition vec3f.hpp:482
const value_type * const_pointer
Definition vec3f.hpp:476
static constexpr int value_alignment
Definition vec3f.hpp:479
Vector3F< value_type > dir
Definition vec3f.hpp:491
2D vector using two value_type components.
Definition vec2f.hpp:41
3D vector using three value_type components.
Definition vec3f.hpp:45
constexpr Vec2 toVec2xy() const noexcept
Returns a Vec2 instance using x and y component, dropping z.
Definition vec3f.hpp:99
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:192
constexpr reference operator[](size_t i) noexcept
Returns writeable reference to component.
Definition vec3f.hpp:111
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:320
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:227
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:141
const value_type & const_reference
Definition vec3f.hpp:51
constexpr bool operator==(const Vector3F &rhs) const noexcept
Definition vec3f.hpp:132
constexpr Vector3F & operator/=(const value_type s) noexcept
this = this / s, component wise.
Definition vec3f.hpp:221
constexpr_cxx26 value_type angle(const Vector3F &o) const noexcept
Return the angle between to vectors in radians.
Definition vec3f.hpp:341
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:332
constexpr Vector3F & normalize() noexcept
Normalize this vector in place.
Definition vec3f.hpp:262
constexpr Vector3F copy() noexcept
Definition vec3f.hpp:96
const value_type * const_pointer
Definition vec3f.hpp:49
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:102
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:182
static constexpr const value_type zero
Definition vec3f.hpp:66
constexpr_cxx23 bool intersects(const Vector3F &o) const noexcept
Definition vec3f.hpp:345
constexpr iterator get(iterator xyz) const noexcept
xyz = this, returns xyz.
Definition vec3f.hpp:120
constexpr Vector3F & set(const value_type vx, const value_type vy, const value_type vz) noexcept
Definition vec3f.hpp:148
constexpr value_type length() const noexcept
Return the length of a vector, a.k.a the norm or magnitude
Definition vec3f.hpp:255
static constexpr const value_type one
Definition vec3f.hpp:67
constexpr Vector3F & scale(const value_type s) noexcept
this = this * s, component wise.
Definition vec3f.hpp:172
constexpr value_type dist(const Vector3F &o) const noexcept
Return the distance between this vector and the given one.
Definition vec3f.hpp:294
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:168
constexpr Vector3F & rotateZ(const value_type sin, const value_type cos) noexcept
Rotates this vector in place, returns *this.
Definition vec3f.hpp:232
constexpr Vector3F & operator+=(const Vector3F &rhs) noexcept
this = this + rhs, component wise.
Definition vec3f.hpp:176
constexpr Vector3F & mul(const Vector3F &s) noexcept
this = this * {s.x, s.y, s.z}, component wise.
Definition vec3f.hpp:164
constexpr value_type dist_sq(const Vector3F &o) const noexcept
Return the squared distance between this vector and the given one.
Definition vec3f.hpp:284
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
static constexpr const size_t components
Definition vec3f.hpp:59
static constexpr int value_alignment
Definition vec3f.hpp:56
static constexpr const size_t byte_size
Definition vec3f.hpp:62
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:160
constexpr const_iterator cbegin() const noexcept
Definition vec3f.hpp:108
constexpr bool is_zero() const noexcept
Definition vec3f.hpp:241
constexpr value_type dot(const Vector3F &o) const noexcept
Return the dot product of this vector and the given one.
Definition vec3f.hpp:302
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:248
constexpr Vector3F(const Vector3F &o) noexcept=default
constexpr Vector3F cross(const Vector3F &b) const noexcept
cross product this x b
Definition vec3f.hpp:310
constexpr Vector3F & set(const_iterator xyz) noexcept
this = xyz, returns this.
Definition vec3f.hpp:152
const value_type * const_iterator
Definition vec3f.hpp:53
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:211
constexpr Vector3F & operator/=(const Vector3F &s) noexcept
this = this / {s.x, s.y, s.z}, component wise.
Definition vec3f.hpp:201
constexpr Vector3F(Vector3F &&o) noexcept=default
constexpr iterator begin() noexcept
Definition vec3f.hpp:117
std::string toString() const noexcept
Definition vec3f.hpp:239
constexpr bool equals(const Vector3F &o, const value_type epsilon=std::numeric_limits< value_type >::epsilon()) const noexcept
Definition vec3f.hpp:123
constexpr Vector3F & add(const Vector3F &d) noexcept
this = this + {d.x, d.y, d.z}, component wise.
Definition vec3f.hpp:156
#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:449
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:502
Vector2F< float > Vec2f
Definition vec2f.hpp:416
constexpr Matrix4< T > operator*(const Matrix4< T > &lhs, const Matrix4< T > &rhs) noexcept
Definition mat4f.hpp:1951
Vector3F< float > Vec3f
Definition vec3f.hpp:436
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:1969
constexpr Vector2F< T > abs(const Vector2F< T > &lhs) noexcept
Definition vec2f.hpp:404
Point3F< float > Point3f
Definition vec3f.hpp:451
uint8_t Value_type