jaulib v1.4.0-2-g788cf73
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 <algorithm>
16#include <cassert>
17#include <cmath>
18#include <cstdarg>
19#include <initializer_list>
20#include <iostream>
21#include <limits>
22#include <string>
23
24#include <jau/float_math.hpp>
25#include <jau/math/vec2f.hpp>
26#include <jau/type_concepts.hpp>
27
28namespace jau::math {
29
30 /** \addtogroup Math
31 *
32 * @{
33 */
34
35 /**
36 * 3D vector using three value_type components.
37 *
38 * Component and overall alignment is natural as sizeof(value_type),
39 * i.e. sizeof(value_type) == alignof(value_type)
40 */
41 template <jau::req::packed_floating_point Value_type>
42 class alignas(sizeof(Value_type)) Vector3F {
43 public:
46 typedef const value_type* const_pointer;
50 typedef const value_type* const_iterator;
51
52 /** value alignment is sizeof(value_type) */
53 constexpr static int value_alignment = sizeof(value_type);
54
55 /** Number of value_type components */
56 constexpr static const size_t components = 3;
57
58 /** Size in bytes with value_alignment */
59 constexpr static const size_t byte_size = components * sizeof(value_type);
60
62
63 constexpr static const value_type zero = value_type(0);
64 constexpr static const value_type one = value_type(1);
65
69
70 constexpr Vector3F() noexcept
71 : x(zero), y(zero), z(zero) {}
72
73 constexpr Vector3F(const value_type v) noexcept
74 : x(v), y(v), z(v) {}
75
76 constexpr Vector3F(const value_type x_, const value_type y_, const value_type z_) noexcept
77 : x(x_), y(y_), z(z_) {}
78
79 constexpr Vector3F(const Vec2& o2, const value_type z_) noexcept
80 : x(o2.x), y(o2.y), z(z_) {}
81
82 constexpr Vector3F(const_iterator v) noexcept
83 : x(v[0]), y(v[1]), z(v[2]) {}
84
85 constexpr Vector3F(std::initializer_list<value_type> v) noexcept
86 : x(v[0]), y(v[1]), z(v[2]) {}
87
88 constexpr Vector3F(const Vector3F& o) noexcept = default;
89 constexpr Vector3F(Vector3F&& o) noexcept = default;
90 constexpr Vector3F& operator=(const Vector3F&) noexcept = default;
91 constexpr Vector3F& operator=(Vector3F&&) noexcept = default;
92
93 constexpr Vector3F copy() noexcept { return Vector3F(*this); }
94
95 /// Returns a Vec2 instance using x and y component, dropping z
96 constexpr Vec2 toVec2xy() const noexcept { return Vec2(x, y); }
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<jau::req::packed_floating_point T>
352 constexpr Vector3F<T> operator+(const Vector3F<T>& lhs, const Vector3F<T>& rhs ) noexcept {
353 // Returning a Vector3 object from the returned reference of operator+=()
354 // may hinder copy-elision or "named return value optimization" (NRVO).
355 // return Vector3<T>(lhs) += rhs;
356
357 // Returning named object allows copy-elision (NRVO),
358 // only one object is created 'on target'.
359 Vector3F<T> r(lhs); r += rhs; return r;
360 }
361
362 template<jau::req::packed_floating_point T>
363 constexpr Vector3F<T> operator-(const Vector3F<T>& lhs, const Vector3F<T>& rhs ) noexcept {
364 Vector3F<T> r(lhs); r -= rhs; return r;
365 }
366
367 template<jau::req::packed_floating_point T>
368 constexpr Vector3F<T> operator-(const Vector3F<T>& lhs) noexcept {
369 Vector3F<T> r(lhs);
370 r *= -1;
371 return r;
372 }
373
374 template<jau::req::packed_floating_point T>
375 constexpr Vector3F<T> operator*(const Vector3F<T>& lhs, const T s ) noexcept {
376 Vector3F<T> r(lhs); r *= s; return r;
377 }
378
379 template<jau::req::packed_floating_point T>
380 constexpr Vector3F<T> operator*(const T s, const Vector3F<T>& rhs) noexcept {
381 Vector3F<T> r(rhs); r *= s; return r;
382 }
383
384 template<jau::req::packed_floating_point T>
385 constexpr Vector3F<T> operator/(const Vector3F<T>& lhs, const T s ) noexcept {
386 Vector3F<T> r(lhs); r /= s; return r;
387 }
388
389 template<jau::req::packed_floating_point T>
390 constexpr Vector3F<T> operator/(const T s, const Vector3F<T>& rhs) noexcept {
391 Vector3F<T> r(rhs);
392 r.x=s/r.x; r.y=s/r.y; r.z=s/r.z;
393 return r;
394 }
395
396 template<jau::req::packed_floating_point T>
397 constexpr Vector3F<T> min(const Vector3F<T>& lhs, const Vector3F<T>& rhs) noexcept {
398 return Vector3F<T>(std::min(lhs.x, rhs.x), std::min(lhs.y, rhs.y), std::min(lhs.z, rhs.z));
399 }
400
401 template<jau::req::packed_floating_point T>
402 constexpr Vector3F<T> max(const Vector3F<T>& lhs, const Vector3F<T>& rhs) noexcept {
403 return Vector3F<T>(std::max(lhs.x, rhs.x), std::max(lhs.y, rhs.y), std::max(lhs.z, rhs.z));
404 }
405
406 template<jau::req::packed_floating_point T>
407 constexpr Vector3F<T> abs(const Vector3F<T>& lhs) noexcept {
408 return Vector3F<T>(std::abs(lhs.x), std::abs(lhs.y), std::abs(lhs.z));
409 }
410
411 template<jau::req::packed_floating_point T>
412 std::ostream& operator<<(std::ostream& out, const Vector3F<T>& v) noexcept {
413 return out << v.toString();
414 }
415
416 static_assert(3 == Vector3F<double>::components);
417 static_assert(sizeof(double) == Vector3F<double>::value_alignment);
418 static_assert(sizeof(double) == alignof(Vector3F<double>));
419 static_assert(sizeof(double)*3 == Vector3F<double>::byte_size);
420 static_assert(sizeof(double)*3 == sizeof(Vector3F<double>));
421
423 static_assert(3 == Vec3f::components);
424 static_assert(sizeof(float) == Vec3f::value_alignment);
425 static_assert(sizeof(float) == alignof(Vec3f));
426 static_assert(sizeof(float)*3 == Vec3f::byte_size);
427 static_assert(sizeof(float)*3 == sizeof(Vec3f));
428
429 /**
430 * Point3F alias of Vector3F
431 */
432 template<typename Value_type,
433 std::enable_if_t<std::is_floating_point_v<Value_type> &&
434 sizeof(Value_type) == alignof(Value_type), bool> = true>
436
438 static_assert(3 == Point3f::components);
439 static_assert(sizeof(float) == Point3f::value_alignment);
440 static_assert(sizeof(float) == alignof(Point3f));
441 static_assert(sizeof(float)*3 == Point3f::byte_size);
442 static_assert(sizeof(float)*3 == sizeof(Point3f));
443
444 /**
445 * Simple compound denoting a ray.
446 *
447 * Component and overall alignment is as sizeof(value_type), i.e. packed.
448 *
449 * A ray, also known as a half line, consists out of it's <i>origin</i>
450 * and <i>direction</i>. Hence it is bound to only the <i>origin</i> side,
451 * where the other end is +infinitive.
452 * <pre>
453 * R(t) = R0 + Rd * t with R0 origin, Rd direction and t > 0.0
454 * </pre>
455 */
456 template <jau::req::packed_floating_point Value_type>
457 class alignas(sizeof(Value_type)) Ray3F {
458 public:
461 typedef const value_type* const_pointer;
462
463 /** value alignment is sizeof(value_type) */
464 constexpr static int value_alignment = sizeof(value_type);
465
466 /** Number of value_type components */
467 constexpr static const size_t components = 6;
468
469 /** Size in bytes with value_alignment */
470 constexpr static const size_t byte_size = components * sizeof(value_type);
471
472 /** Origin of Ray. */
474
475 /** Normalized direction vector of ray. */
477
478 std::string toString() const noexcept { return "Ray[orig "+orig.toString()+", dir "+dir.toString() +"]"; }
479 };
480
481 template <jau::req::packed_floating_point T>
482 std::ostream& operator<<(std::ostream& out, const Ray3F<T>& v) noexcept {
483 return out << v.toString();
484 }
485
487 static_assert(6 == Ray3f::components);
488 static_assert(sizeof(float) == Ray3f::value_alignment);
489 static_assert(sizeof(float) == alignof(Ray3f));
490 static_assert(sizeof(float)*6 == Ray3f::byte_size);
491 static_assert(sizeof(float)*6 == sizeof(Ray3f));
492
493 /**@}*/
494
495} // namespace jau::math
496
497#endif /* JAU_MATH_VEC3F_HPP_ */
Simple compound denoting a ray.
Definition vec3f.hpp:457
static constexpr const size_t components
Definition vec3f.hpp:467
Point3F< value_type > orig
Definition vec3f.hpp:473
const value_type * const_pointer
Definition vec3f.hpp:461
Vector3F< value_type > dir
Definition vec3f.hpp:476
static constexpr int value_alignment
Definition vec3f.hpp:464
std::string toString() const noexcept
Definition vec3f.hpp:478
static constexpr const size_t byte_size
Definition vec3f.hpp:470
2D vector using two value_type components.
Definition vec2f.hpp:40
3D vector using three value_type components.
Definition vec3f.hpp:42
constexpr bool is_zero() const noexcept
Definition vec3f.hpp:238
constexpr Vector3F(const Vec2 &o2, const value_type z_) noexcept
Definition vec3f.hpp:79
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 Vector3F & normalize() noexcept
Normalize this vector in place.
Definition vec3f.hpp:259
static constexpr const size_t byte_size
Definition vec3f.hpp:59
const value_type * const_iterator
Definition vec3f.hpp:50
constexpr Vector3F cross(const Vector3F &b) const noexcept
cross product this x b
Definition vec3f.hpp:307
constexpr Vector3F & operator-=(const Vector3F &rhs) noexcept
this = this - rhs, component wise.
Definition vec3f.hpp:179
constexpr Vector3F & operator=(Vector3F &&) noexcept=default
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_cxx26 value_type angle(const Vector3F &o) const noexcept
Return the angle between to vectors in radians.
Definition vec3f.hpp:338
constexpr const_iterator cbegin() const noexcept
Definition vec3f.hpp:105
const value_type * const_pointer
Definition vec3f.hpp:46
constexpr_cxx23 bool intersects(const Vector3F &o) const noexcept
Definition vec3f.hpp:342
constexpr Vector3F & operator+=(const Vector3F &rhs) noexcept
this = this + rhs, component wise.
Definition vec3f.hpp:173
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
static constexpr const size_t components
Definition vec3f.hpp:56
constexpr Vector3F & operator/=(const value_type s) noexcept
this = this / s, component wise.
Definition vec3f.hpp:218
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 iterator begin() noexcept
Definition vec3f.hpp:114
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 & set(const_iterator xyz) noexcept
this = xyz, returns this.
Definition vec3f.hpp:149
const value_type & const_reference
Definition vec3f.hpp:48
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(const value_type x_, const value_type y_, const value_type z_) noexcept
Definition vec3f.hpp:76
constexpr_cxx26 Vector3F & rotateZ(const value_type radians) noexcept
Rotates this vector around the Z-axis in place, returns *this.
Definition vec3f.hpp:224
static constexpr int value_alignment
Definition vec3f.hpp:53
constexpr Vector3F(Vector3F &&o) noexcept=default
constexpr Vector3F & set(const value_type vx, const value_type vy, const value_type vz) noexcept
Definition vec3f.hpp:145
std::string toString() const noexcept
Definition vec3f.hpp:236
constexpr Vec2 toVec2xy() const noexcept
Returns a Vec2 instance using x and y component, dropping z.
Definition vec3f.hpp:96
constexpr Vector3F() noexcept
Definition vec3f.hpp:70
constexpr bool operator==(const Vector3F &rhs) const noexcept
Definition vec3f.hpp:129
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 reference operator[](size_t i) noexcept
Returns writeable reference to component.
Definition vec3f.hpp:108
constexpr Vector3F & operator*=(const Vector3F &s) noexcept
this = this * {s.x, s.y, s.z}, component wise.
Definition vec3f.hpp:189
Vector2F< value_type > Vec2
Definition vec3f.hpp:61
constexpr bool equals(const Vector3F &o, const value_type epsilon=std::numeric_limits< value_type >::epsilon()) const noexcept
Definition vec3f.hpp:120
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 Vector3F & operator*=(const value_type s) noexcept
this = this * s, component wise.
Definition vec3f.hpp:208
constexpr Vector3F(const Vector3F &o) noexcept=default
constexpr Vector3F(std::initializer_list< value_type > v) noexcept
Definition vec3f.hpp:85
constexpr Vector3F & scale(const value_type s) noexcept
this = this * s, component wise.
Definition vec3f.hpp:169
constexpr Vector3F(const value_type v) noexcept
Definition vec3f.hpp:73
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:82
constexpr iterator get(iterator xyz) const noexcept
xyz = this, returns xyz.
Definition vec3f.hpp:117
constexpr Vector3F & mul(const Vector3F &s) noexcept
this = this * {s.x, s.y, s.z}, component wise.
Definition vec3f.hpp:161
constexpr Vector3F & operator/=(const Vector3F &s) noexcept
this = this / {s.x, s.y, s.z}, component wise.
Definition vec3f.hpp:198
constexpr Vector3F & add(const Vector3F &d) noexcept
this = this + {d.x, d.y, d.z}, component wise.
Definition vec3f.hpp:153
static constexpr const value_type one
Definition vec3f.hpp:64
constexpr value_type dist(const Vector3F &o) const noexcept
Return the distance between this vector and the given one.
Definition vec3f.hpp:291
constexpr value_type cos_angle(const Vector3F &o) const noexcept
Return the cosines of the angle between to vectors.
Definition vec3f.hpp:329
static constexpr const value_type zero
Definition vec3f.hpp:63
constexpr Vector3F & operator=(const Vector3F &) noexcept=default
constexpr Vector3F copy() noexcept
Definition vec3f.hpp:93
#define constexpr_cxx23
#define constexpr_cxx26
constexpr bool 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.
constexpr bool 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:435
constexpr Quaternion< T > operator-(const Quaternion< T > &lhs, const Quaternion< T > &rhs) noexcept
constexpr Matrix4< T > operator*(const Matrix4< T > &lhs, const Matrix4< T > &rhs) noexcept
Definition mat4f.hpp:1949
constexpr Vector2F< T > abs(const Vector2F< T > &lhs) noexcept
Definition vec2f.hpp:393
constexpr Quaternion< T > operator+(const Quaternion< T > &lhs, const Quaternion< T > &rhs) noexcept
Ray3F< float > Ray3f
Definition vec3f.hpp:486
constexpr Vector2F< T > max(const Vector2F< T > &lhs, const Vector2F< T > &rhs) noexcept
Definition vec2f.hpp:388
Vector2F< float > Vec2f
Definition vec2f.hpp:404
std::ostream & operator<<(std::ostream &out, const Matrix4< T > &v) noexcept
Definition mat4f.hpp:1964
constexpr Vector2F< T > min(const Vector2F< T > &lhs, const Vector2F< T > &rhs) noexcept
Definition vec2f.hpp:383
Vector3F< float > Vec3f
Definition vec3f.hpp:422
Point3F< float > Point3f
Definition vec3f.hpp:437
constexpr Vector2F< T > operator/(const Vector2F< T > &lhs, const T s) noexcept
Definition vec2f.hpp:371
uint8_t Value_type