EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_Affine.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Robert Marskar <robert.marskar@sintef.no>
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
14#ifndef EBGEOMETRY_AFFINE_HPP
15#define EBGEOMETRY_AFFINE_HPP
16
17// Std includes
18#include <cstddef>
19#include <type_traits>
20
21// Our includes
23#include "EBGeometry_GPU.hpp"
24#include "EBGeometry_Vec.hpp"
25
26namespace EBGeometry {
27
35template <class T>
37{
38 static_assert(std::is_floating_point_v<T>, "Affine3T requires a floating-point type T");
39
44
49
54
59
64 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
65 static inline Affine3T
66 identity() noexcept;
67
73 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
74 static inline Affine3T
75 translation(const Vec3T<T>& a_shift) noexcept;
76
83 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
84 static inline Affine3T
85 rotation(const T a_degrees, const size_t a_axis) noexcept;
86
94 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
95 static inline Affine3T
96 rotation(const T a_degrees, const Vec3T<T>& a_axis) noexcept;
97
103 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
104 static inline Affine3T
105 scaling(const T a_factor) noexcept;
106
112 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
113 static inline Affine3T
114 reflection(const size_t a_axis) noexcept;
115
121 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
122 inline Vec3T<T>
123 operator()(const Vec3T<T>& a_point) const noexcept;
124
130 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
131 inline Affine3T
132 then(const Affine3T& a_next) const noexcept;
133
139 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
140 inline bool
141 isAxisAligned() const noexcept;
142
152 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
153 inline BoundingVolumes::AABBT<T>
154 transform(const BoundingVolumes::AABBT<T>& a_box) const noexcept;
155};
156
157static_assert(std::is_trivially_copyable_v<Affine3T<float>>, "Affine3T<float> must be trivially copyable");
158static_assert(std::is_trivially_copyable_v<Affine3T<double>>, "Affine3T<double> must be trivially copyable");
159
160} // namespace EBGeometry
161
162#include "EBGeometry_AffineImplem.hpp"
163
164#endif
Declarations of bounding volume types used in bounding volume hierarchies.
GPU portability layer: host/device decoration macros and backend detection.
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
Declaration of 2D and 3D point/vector classes with templated precision, and free functions on them.
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
An affine map of 3D space, x -> A x + b, with A stored by rows.
Definition EBGeometry_Affine.hpp:37
BoundingVolumes::AABBT< T > transform(const BoundingVolumes::AABBT< T > &a_box) const noexcept
A box enclosing the image of a box under the map.
static Affine3T translation(const Vec3T< T > &a_shift) noexcept
A translation.
static Affine3T rotation(const T a_degrees, const size_t a_axis) noexcept
A rotation about a coordinate axis, counterclockwise seen from the positive end of the axis.
Vec3T< T > m_row1
Second row of A.
Definition EBGeometry_Affine.hpp:48
static Affine3T scaling(const T a_factor) noexcept
A uniform scaling.
Vec3T< T > m_row0
First row of A.
Definition EBGeometry_Affine.hpp:43
bool isAxisAligned() const noexcept
Whether every row of A has at most one non-zero entry, so that the map sends axis-aligned boxes to ax...
Vec3T< T > m_row2
Third row of A.
Definition EBGeometry_Affine.hpp:53
static Affine3T reflection(const size_t a_axis) noexcept
A reflection in a coordinate plane through the origin.
Vec3T< T > m_shift
The shift b.
Definition EBGeometry_Affine.hpp:58
Affine3T then(const Affine3T &a_next) const noexcept
The map that applies this one and then a_next.
static Affine3T identity() noexcept
The identity map.