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