CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Geometry.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Forward.hpp"
11
14
19
23
24#include <iosfwd>
25
26#if defined(far)
27#undef far
28#endif
29#if defined(near)
30#undef near
31#endif
32
33namespace CeresEngine::inline Math {
34
35 template<typename T> struct TAABox;
36 template<typename T> struct TLineSegment;
37 template<typename T> struct TCapsule;
38 template<typename T> struct TPlane;
39 template<typename T> struct TRect;
40 template<typename T> struct TSphere;
41 template<typename T> struct TConvexVolume;
42 template<typename T> struct TRayIntersection;
43 template<typename T> struct TRay;
44
46 template<typename T> struct TAABox {
50 TVector3<T> minimum = Vector3(-T(0.5), -T(0.5), -T(0.5));
51
55 TVector3<T> maximum = Vector3(T(0.5), T(0.5), T(0.5));
56
57 public:
68 enum Corner {
69 FarLeftBottom = 0,
70 FarLeftTop = 1,
71 FarRightTop = 2,
72 FarRightBottom = 3,
73 NearRightBottom = 7,
74 NearLeftBottom = 6,
75 NearLeftTop = 5,
76 NearRightTop = 4
77 };
78
80 TAABox() = default;
81
83 TAABox(const TVector3<T>& min, const TVector3<T>& max);
84
86 explicit TAABox(const TSphere<T>& sphere) : minimum(sphere.center - sphere.radius), maximum(sphere.center + sphere.radius) {}
87
89 TAABox(const TAABox&) = default;
90
91 ~TAABox() = default;
92
93 public:
96 [[nodiscard]] CE_SCRIPT_EXPORT()
97 TAABox scale(const TVector3<T>& s) const;
98
100 [[nodiscard]] CE_SCRIPT_EXPORT()
101 TAABox translate(const TVector3<T>& t) const;
102
104 [[nodiscard]] TVector3<T> getCorner(Corner cornerToGet) const noexcept;
105
107 [[nodiscard]] Array<TVector3<T>, 8> getCorners() const noexcept;
108
112 TAABox merge(const TAABox& rhs);
113
116 TAABox merge(const TVector3<T>& point);
117
125 void transform(const TMatrix4<T>& matrix);
126
128 void transform(const TTransform<T>& aTransform) { transform(aTransform.getMatrix()); }
129
131 [[nodiscard]] CE_SCRIPT_EXPORT()
132 bool intersects(const TAABox& b2) const;
133
135 [[nodiscard]] CE_SCRIPT_EXPORT()
136 bool intersects(const TSphere<T>& s) const;
137
139 [[nodiscard]] CE_SCRIPT_EXPORT()
140 bool intersects(const TPlane<T>& p) const;
141
144 [[nodiscard]] CE_SCRIPT_EXPORT()
145 TRayIntersection<T> intersects(const TRay<T>& ray) const;
146
150 bool intersects(const TRay<T>& ray, T& d1, T& d2) const;
151
153 [[nodiscard]] CE_SCRIPT_EXPORT()
154 bool contains(const TVector3<T>& v) const;
155
157 [[nodiscard]] CE_SCRIPT_EXPORT()
159 bool contains(const TVector3<T>& v, T extra) const;
160
163 [[nodiscard]] CE_SCRIPT_EXPORT()
164 bool contains(const TAABox& other) const;
165
167 [[nodiscard]] CE_SCRIPT_EXPORT()
168 bool contains(const TSphere<T>& s) const;
169
171 [[nodiscard]] CE_SCRIPT_EXPORT()
172 TVector3<T> getCenter() const;
173
175 [[nodiscard]] CE_SCRIPT_EXPORT()
176 TVector3<T> getSize() const;
177
179 [[nodiscard]] CE_SCRIPT_EXPORT()
180 TVector3<T> getHalfSize() const;
181
183 [[nodiscard]] CE_SCRIPT_EXPORT()
184 T getRadius() const;
185
187 [[nodiscard]] CE_SCRIPT_EXPORT()
188 T getVolume() const;
189
190 public:
191 friend bool operator==(const TAABox& lhs, const TAABox& rhs) { return lhs.minimum == rhs.minimum && lhs.maximum == rhs.maximum; }
192
193 friend bool operator!=(const TAABox& lhs, const TAABox& rhs) { return !(lhs == rhs); }
194
200 friend TAABox operator+(const TAABox& lhs, const TAABox& rhs) {
201 TAABox copy = lhs;
202 copy.merge(rhs);
203 return copy;
204 }
205
211 friend TAABox& operator+=(TAABox& lhs, const TAABox& rhs) {
212 lhs.merge(rhs);
213 return lhs;
214 }
215
220 friend TAABox operator+(const TAABox& lhs, const TVector3<T>& rhs) {
221 TAABox copy = lhs;
222 copy.merge(rhs);
223 return copy;
224 }
225
230 friend TAABox& operator+=(TAABox& lhs, const TVector3<T>& rhs) {
231 lhs.merge(rhs);
232 return lhs;
233 }
234
241 friend TAABox operator*(const TMatrix4<T>& lhs, TAABox rhs) {
242 rhs.transform(lhs);
243 return rhs;
244 }
245
252 friend TAABox operator*(const TTransform<T>& lhs, TAABox rhs) {
253 rhs.transform(lhs);
254 return rhs;
255 }
256
257 public:
259 static const TAABox empty;
260
262 static const TAABox unit;
263
265 static const TAABox infinity;
266
270 template<typename I = UInt32>
271 static inline constexpr I CUBE_INDICES[] = {
272 // Near
273 NearLeftBottom, NearLeftTop, NearRightTop, NearLeftBottom, NearRightTop, NearRightBottom,
274
275 // Far
276 FarRightBottom, FarRightTop, FarLeftTop, FarRightBottom, FarLeftTop, FarLeftBottom,
277
278 // Left
279 FarLeftBottom, FarLeftTop, NearLeftTop, FarLeftBottom, NearLeftTop, NearLeftBottom,
280
281 // Right
282 NearRightBottom, NearRightTop, FarRightTop, NearRightBottom, FarRightTop, FarRightBottom,
283
284 // Top
285 FarLeftTop, FarRightTop, NearRightTop, FarLeftTop, NearRightTop, NearLeftTop,
286
287 // Bottom
288 NearLeftBottom, NearRightBottom, FarRightBottom, NearLeftBottom, FarRightBottom, FarLeftBottom};
289 };
290
291 extern template struct TAABox<double>;
292 extern template struct TAABox<float>;
293
298 template<typename T> std::ostream& operator<<(std::ostream& os, const TAABox<T>& box);
299
300 extern template std::ostream& operator<<(std::ostream& os, const TAABox<double>& box);
301 extern template std::ostream& operator<<(std::ostream& os, const TAABox<float>& box);
302
303 // ---------------------------------------------------------------------------------------------
304
307 template<typename T> struct TLineSegment {
309 TVector3<T> start = TVector3<T>(0.0);
310
312 TVector3<T> end = TVector3<T>(0.0);
313
314 public:
317
319 TLineSegment(const TVector3<T>& start, const TVector3<T>& end) : start(start), end(end) {}
320
321 public:
329
332 T getLength() const { return distance(start, end); }
333
336 TVector3<T> getCenter() const { return start + (end - start) * T(0.5); }
337 };
338
339 extern template struct TLineSegment<double>;
340 extern template struct TLineSegment<float>;
341
343 template<typename T> struct TCapsule {
345 TLineSegment<T> segment;
346
348 T radius = T(0.0);
349
350 public:
353
355 TCapsule(const TLineSegment<T>& segment, T radius);
356
357 public:
363
364 public:
368 T getHeight() const { return segment.getLength(); }
369
372 TVector3<T> getCenter() const { return segment.getCenter(); }
373 };
374
375 extern template struct TCapsule<double>;
376 extern template struct TCapsule<float>;
377
379 template<typename T> struct TPlane {
381 TVector3<T> normal = TVector3<T>(T(0.0));
382
384 T distance = T(0.0);
385
386 public:
391 None = 0U,
392 Positive = (1U << 0U),
393 Negative = (1U << 1U),
394 Both = Positive | Negative
395 };
396
397 public:
400
403
405 TPlane(const TVector3<T>& normal, T d) : normal(normal), distance(d) {}
406
408 explicit TPlane(const TVector4<T>& data) : normal(data.x, data.y, data.z), distance(data.w) {}
409
411 TPlane(T a, T b, T c, T d) : normal(a, b, c), distance(d) {}
412
414 TPlane(const TVector3<T>& normal, const TVector3<T>& point) : normal(normal), distance(dot(normal, point)) {}
415
418
420
424
427
430 [[nodiscard]] Side getSide(const TVector3<T>& point, T epsilon = 0.0) const;
431
435 [[nodiscard]] Side getSide(const TAABox<T>& box) const;
436
440
445 [[nodiscard]] CE_SCRIPT_EXPORT(name = "getDistanceToPoint")
446 T getDistance(const TVector3<T>& point) const;
447
450 TVector3<T> projectVector(const TVector3<T>& v) const;
451
454 T normalize();
455
458 bool intersects(const TAABox<T>& box) const;
459
462 bool intersects(const TSphere<T>& sphere) const;
463
468
469 bool operator==(const TPlane& rhs) const { return (rhs.distance == distance && rhs.normal == normal); }
470 bool operator!=(const TPlane& rhs) const { return (rhs.distance != distance || rhs.normal != normal); }
471 };
472
473 extern template struct TPlane<double>;
474 extern template struct TPlane<float>;
475
480 template<typename T> struct TRect {
481 private:
482 TVector3<T> mCenter = TVector3<T>(T(0.0));
483 TVector3<T> mAxisHorz = TVector3<T>(T(0.0));
484 TVector3<T> mAxisVert = TVector3<T>(T(0.0));
485
486 T mExtentHorz = T(0.0);
487 T mExtentVert = T(0.0);
488
489 public:
490 TRect() = default;
491
492 TRect(const TVector3<T>& center, const Array<TVector3<T>, 2>& axes, const Array<T, 2>& extents)
493 : mCenter(center), mAxisHorz(axes[0]), mAxisVert(axes[1]), mExtentHorz(extents[0]), mExtentVert(extents[1]) {}
494
503
507
511
513 [[nodiscard]] const TVector3<T>& getCenter() const { return mCenter; }
514
516 [[nodiscard]] const TVector3<T>& getAxisHorz() const { return mAxisHorz; }
517
519 [[nodiscard]] const TVector3<T>& getAxisVert() const { return mAxisVert; }
520
522 [[nodiscard]] const T& getExtentHorz() const { return mExtentHorz; }
523
525 [[nodiscard]] const T& getExtentVertical() const { return mExtentVert; }
526
527 friend struct std::hash<TRect>;
528 };
529
530 extern template struct TRect<double>;
531 extern template struct TRect<float>;
532
534 template<typename T> struct TSphere {
537 T radius = T(1.0);
538
541 TVector3<T> center = TVector3<T>(T(0.0));
542
543 public:
547
549 TSphere(const TVector3<T>& center, T radius) : radius(radius), center(center) {}
550
552 explicit TSphere(const TAABox<T>& box) : radius(box.getRadius()), center(box.getCenter()) {}
553
554 public:
558 void merge(const TSphere& rhs);
559
562 void merge(const TVector3<T>& point);
563
567
570
573 bool contains(const TVector3<T>& v) const;
574
577 bool contains(const TAABox<T>& box) const;
578
581 bool intersects(const TSphere& s) const;
582
585 bool intersects(const TAABox<T>& box) const;
586
589 bool intersects(const TPlane<T>& plane) const;
590
599
602 [[nodiscard]] T distance(const TVector3<T>& point) const;
603
606
607 public:
611 lhs.merge(rhs);
612 return lhs;
613 }
614
617 friend TSphere& operator+=(TSphere& lhs, const TSphere& rhs) {
618 lhs.merge(rhs);
619 return lhs;
620 }
621
623 friend TSphere operator+(TSphere lhs, const TVector3<T>& rhs) {
624 lhs.merge(rhs);
625 return lhs;
626 }
627
629 friend TSphere& operator+=(TSphere& lhs, const TVector3<T>& rhs) {
630 lhs.merge(rhs);
631 return lhs;
632 }
633
635 friend TSphere operator*(const TMatrix4<T>& lhs, TSphere rhs) {
636 rhs.transform(lhs);
637 return rhs;
638 }
639
641 friend TSphere operator*(const TTransform<T>& lhs, TSphere rhs) {
642 rhs.transform(lhs);
643 return rhs;
644 }
645
646 public:
649
652
655 };
656
659
662 Left = 0,
663 Right = 1,
664 Top = 2,
665 Bottom = 3,
666 Far = 4,
667 Near = 5
668 };
669
672 template<typename T> struct TConvexVolume {
675 SmallVector<TPlane<T>, 10> planes;
676
677 public:
680
682 explicit TConvexVolume(SmallVector<TPlane<T>, 10> planes) : planes(std::move(planes)) {}
683
687
691
694
698 bool intersects(const TAABox<T>& box) const;
699
703 bool intersects(const TSphere<T>& sphere) const;
704
711
718 bool contains(const TVector3<T>& p, T expand = 0.0) const;
719
723
724 public:
727 rhs.transform(lhs);
728 return rhs;
729 }
730
733 rhs.transform(lhs);
734 return rhs;
735 }
736 };
737
738 extern template struct TConvexVolume<double>;
739 extern template struct TConvexVolume<float>;
740
742 template<typename T> struct TRayIntersection {
745 bool intersects = false;
746
749 T distance = T(0.0);
750
754
758 TRayIntersection(T distance) : intersects(true), distance(distance) {} // NOLINT
759
761 explicit operator bool() const noexcept { return intersects; }
762 };
763
764 extern template struct TRayIntersection<double>;
765 extern template struct TRayIntersection<float>;
766
768 template<typename T> struct TRay {
771 TVector3<T> origin = TVector3<T>(T(0.0));
772
775 TVector3<T> direction = TVector3<T>(T(0.0), T(0.0), T(1.0));
776
777 public:
781
787 constexpr TRay(const TVector3<T>& origin, const TVector3<T>& direction) : origin(origin), direction(direction) {}
788
789 public:
792 constexpr TVector3<T> getPoint(T t) const { return TVector3<T>(origin + (direction * t)); }
793
797
800
805
810
815
832 bool negativeSide = true) const;
833
834 public:
836 constexpr TVector3<T> operator[](T t) const { return getPoint(t); }
837
842 friend TRay<T> operator*(const TMatrix4<T>& lhs, TRay<T> rhs) {
843 rhs.transform(lhs);
844 return rhs;
845 }
846
851 friend TRay<T> operator*(const TTransform<T>& lhs, TRay<T> rhs) {
852 rhs.transform(lhs);
853 return rhs;
854 }
855 };
856
857 extern template struct TRay<double>;
858 extern template struct TRay<float>;
859
864 template<typename T> std::ostream& operator<<(std::ostream& os, const TRay<T>& ray);
865
866 extern template std::ostream& operator<<(std::ostream&, const TRay<double>&);
867 extern template std::ostream& operator<<(std::ostream&, const TRay<float>&);
868
873 template<typename T> std::ostream& operator<<(std::ostream& os, const TRayIntersection<T>& intersection);
874
875 extern template std::ostream& operator<<(std::ostream&, const TRayIntersection<double>&);
876 extern template std::ostream& operator<<(std::ostream&, const TRayIntersection<float>&);
877
882
887
892
897
902
907
912
917
922} // namespace CeresEngine::inline Math
923
924template<typename T> struct std::hash<CeresEngine::TAABox<T>> {
925 using Type = CeresEngine::TAABox<T>;
926 size_t operator()(const Type& obj) const { return CeresEngine::hash(obj.minimum, obj.maximum); }
927};
928
929template<typename T> struct std::hash<CeresEngine::TLineSegment<T>> {
930 using Type = CeresEngine::TLineSegment<T>;
931 size_t operator()(const Type& obj) const { return CeresEngine::hash(obj.start, obj.end); }
932};
933
934template<typename T> struct std::hash<CeresEngine::TCapsule<T>> {
935 using Type = CeresEngine::TCapsule<T>;
936 size_t operator()(const Type& obj) const { return CeresEngine::hash(obj.segment, obj.radius); }
937};
938
939template<typename T> struct std::hash<CeresEngine::TConvexVolume<T>> {
941 size_t operator()(const Type& obj) const { return CeresEngine::hash(obj.planes); }
942};
943
944template<typename T> struct std::hash<CeresEngine::TPlane<T>> {
945 using Type = CeresEngine::TPlane<T>;
946 size_t operator()(const Type& obj) const { return CeresEngine::hash(obj.normal, obj.distance); }
947};
948
949template<typename T> struct std::hash<CeresEngine::TRect<T>> {
950 using Type = CeresEngine::TRect<T>;
951 size_t operator()(const Type& obj) const { return CeresEngine::hash(obj.mCenter, obj.mAxisHorz, obj.mAxisVert, obj.mExtentHorz, obj.mExtentVert); }
952};
953
954template<typename T> struct std::hash<CeresEngine::TSphere<T>> {
955 using Type = CeresEngine::TSphere<T>;
956 size_t operator()(const Type& obj) const { return CeresEngine::hash(obj.center, obj.radius); }
957};
958
959template<> struct std::hash<CeresEngine::FrustumPlane> {
960 using Type = CeresEngine::FrustumPlane;
961 size_t operator()(const Type& obj) const { return CeresEngine::hash(obj); }
962};
963
964template<typename T> struct std::hash<CeresEngine::TRayIntersection<T>> {
966 size_t operator()(const Type& obj) const { return CeresEngine::hash(obj.distance, obj.intersects); }
967};
968
969template<typename T> struct std::hash<CeresEngine::TRay<T>> {
970 using Type = CeresEngine::TRay<T>;
971 size_t operator()(const Type& obj) const { return CeresEngine::hash(obj.origin, obj.direction); }
972};
#define CE_SCRIPT_EXPORT(...)
The CE_SCRIPT_EXPORT macro marks a class or method as exportable and available in scripting environme...
Definition Macros.hpp:247
Definition Application.hpp:19
Box box(T &value)
Creates a new Box object by wraping the value as a reference type.
Definition Box.hpp:672
constexpr Byte operator<<(const Byte arg, const _IntType shift) noexcept
Definition DataTypes.hpp:44
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
sfl::small_vector< T, N, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > SmallVector
SmallVector is a sequence container similar to Vector.
Definition SmallVector.hpp:31
std::array< T, N > Array
Array is a container that encapsulates fixed size arrays.
Definition Array.hpp:17
std::uint32_t UInt32
Definition DataTypes.hpp:23
auto transform(Container &container, Transform &&transform)
Returns an iterable object that iterates over the values of the container and applies transform to ev...
Definition Iterator.hpp:436
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Angle.hpp:20
TVector3< double > Vector3
A three dimensional vector with (x, y, z) coordinates.
Definition Vector.hpp:84
TMatrix< 4, 4, T > TMatrix4
A 4x4 type that uses a internal representation of type T
Definition Matrix.hpp:54
TVector< 4, T > TVector4
A four dimensional vector type that uses a internal representation of type T
Definition Vector.hpp:115
TVector3< T > normal(const TVector3< T > &p1, const TVector3< T > &p2, const TVector3< T > &p3)
Definition Math.hpp:704
TVector< 3, T > TVector3
A three dimensional vector type that uses a internal representation of type T
Definition Vector.hpp:80
FrustumPlane
Clip planes that form the camera frustum (visible area).
Definition Geometry.hpp:661
Definition Span.hpp:668
Axis aligned box represented by minimum and maximum point.
Definition Geometry.hpp:46
friend bool operator!=(const TAABox &lhs, const TAABox &rhs)
Definition Geometry.hpp:193
friend TAABox & operator+=(TAABox &lhs, const TAABox &rhs)
Merges the two boxes, creating a new bounding box that encapsulates them both.
Definition Geometry.hpp:211
friend TAABox operator+(const TAABox &lhs, const TVector3< T > &rhs)
Expands the bounding box so it includes the provided point.
Definition Geometry.hpp:220
Corner
Different corners of a box.
Definition Geometry.hpp:68
TAABox merge(const TAABox &rhs)
Merges the two boxes, creating a new bounding box that encapsulates them both.
friend TAABox & operator+=(TAABox &lhs, const TVector3< T > &rhs)
Expands the bounding box so it includes the provided point.
Definition Geometry.hpp:230
void transform(const TMatrix4< T > &matrix)
Transforms the bounding box by the given matrix.
friend TAABox operator*(const TMatrix4< T > &lhs, TAABox rhs)
Transforms the bounding box by the given matrix.
Definition Geometry.hpp:241
friend TAABox operator+(const TAABox &lhs, const TAABox &rhs)
Merges the two boxes, creating a new bounding box that encapsulates them both.
Definition Geometry.hpp:200
friend TAABox operator*(const TTransform< T > &lhs, TAABox rhs)
Transforms the bounding box by the given transform.
Definition Geometry.hpp:252
void transform(const TTransform< T > &aTransform)
Transforms the bounding box by the given matrix.
Definition Geometry.hpp:128
Represents a capsule with a line segment and a radius.
Definition Geometry.hpp:343
Represents a convex volume defined by planes representing the volume border.
Definition Geometry.hpp:672
friend TConvexVolume operator*(const TTransform< T > &lhs, TConvexVolume rhs)
Transforms the convex volume by the given transform.
Definition Geometry.hpp:732
void transform(const TTransform< T > &aTransform)
Transforms the convex volume by the given matrix.
Definition Geometry.hpp:693
void transform(const TMatrix4< T > &matrix)
Transforms the convex volume by the given matrix.
Represents a line segment in three dimensional space defined by a start and an end point.
Definition Geometry.hpp:307
Pair< Array< TVector3< T >, 2 >, T > getNearestPoint(const TRay< T > &ray) const
Find the nearest point on the line segment and the provided ray.
A plane represented by a normal and a distance.
Definition Geometry.hpp:379
TVector3< T > normal
Definition Geometry.hpp:381
Side getSide(const TSphere< T > &sphere) const
Returns the side where the sphere is.
bool operator!=(const TPlane &rhs) const
Definition Geometry.hpp:470
Side
The "positive side" of the plane is the half space to which the plane normal points.
Definition Geometry.hpp:390
void transform(const TTransform< T > &aTransform)
Transforms the plane by the given matrix.
Definition Geometry.hpp:426
Side getSide(const TAABox< T > &box) const
Returns the side where the alignedBox is.
T distance
Definition Geometry.hpp:384
Side getSide(const TVector3< T > &point, T epsilon=0.0) const
Returns the side of the plane where the point is located on.
A ray in 3D space represented with an origin and direction.
Definition Geometry.hpp:768
void transform(const TTransform< T > &aTransform)
Transforms the ray by the given matrix.
Definition Geometry.hpp:799
friend TRay< T > operator*(const TTransform< T > &lhs, TRay< T > rhs)
Transforms the ray by the given transform.
Definition Geometry.hpp:851
void transform(const TMatrix4< T > &matrix)
Transforms the ray by the given matrix.
friend TRay< T > operator*(const TMatrix4< T > &lhs, TRay< T > rhs)
Transforms the ray by the given matrix.
Definition Geometry.hpp:842
A structure that describes an intersection with a ray.
Definition Geometry.hpp:742
Represents a rectangle in three dimensional space.
Definition Geometry.hpp:480
const T & getExtentHorz() const
Gets the extent of the rectangle along its horizontal axis.
Definition Geometry.hpp:522
TRect()=default
const TVector3< T > & getAxisHorz() const
Returns the rectangle's horizontal axis.
Definition Geometry.hpp:516
const T & getExtentVertical() const
Gets the extent of the rectangle along its vertical axis.
Definition Geometry.hpp:525
const TVector3< T > & getAxisVert() const
Returns the rectangle's vertical axis.
Definition Geometry.hpp:519
Pair< TVector3< T >, T > getNearestPoint(const TVector3< T > &point) const
Find the nearest point on the rectangle to the provided point.
Pair< Array< TVector3< T >, 2 >, T > getNearestPoint(const TRay< T > &ray) const
Find the nearest points of the provided ray and the rectangle.
TRect(const TVector3< T > &center, const Array< TVector3< T >, 2 > &axes, const Array< T, 2 > &extents)
Definition Geometry.hpp:492
const TVector3< T > & getCenter() const
Gets the origin of the rectangle.
Definition Geometry.hpp:513
TRayIntersection< T > intersects(const TRay< T > &ray) const
Ray/rectangle intersection.
A sphere represented by a center point and a radius.
Definition Geometry.hpp:534
void merge(const TSphere &rhs)
Merges the two spheres, creating a new sphere that encapsulates them both.
friend TSphere & operator+=(TSphere &lhs, const TVector3< T > &rhs)
Expands the sphere so it includes the provided point.
Definition Geometry.hpp:629
friend TSphere operator*(const TTransform< T > &lhs, TSphere rhs)
Transforms the sphere by the given matrix.
Definition Geometry.hpp:641
friend TSphere & operator+=(TSphere &lhs, const TSphere &rhs)
Merges the two spheres, creating a new sphere that encapsulates them both.
Definition Geometry.hpp:617
void transform(const TMatrix4< T > &matrix)
Transforms the sphere by the given matrix.
void transform(const TTransform< T > &aTransform)
Transforms the sphere by the given matrix.
Definition Geometry.hpp:569
friend TSphere operator+(TSphere lhs, const TVector3< T > &rhs)
Expands the sphere so it includes the provided point.
Definition Geometry.hpp:623
friend TSphere operator*(const TMatrix4< T > &lhs, TSphere rhs)
Transforms the sphere by the given matrix.
Definition Geometry.hpp:635
A class that simplifies working with transformation matrices.
Definition Transform.hpp:62