20 #ifndef ANTKEEPER_GEOM_COORDINATES_HPP
21 #define ANTKEEPER_GEOM_COORDINATES_HPP
66 return !
static_cast<bool>(region);
78 return std::has_single_bit(
static_cast<std::uint8_t
>(region));
90 return static_cast<bool>(region) && !std::has_single_bit(
static_cast<std::uint8_t
>(region));
102 return static_cast<std::uint8_t
>(region) & std::uint8_t{0b11};
114 return std::uint8_t{3} - (
static_cast<std::uint8_t
>(region) >> 1);
129 std::uint8_t region =
static_cast<std::uint8_t
>(p.x() <= T{0});
130 region |=
static_cast<std::uint8_t
>(p.y() <= T{0}) << std::uint8_t{1};
131 region |=
static_cast<std::uint8_t
>(p.z() <= T{0}) << std::uint8_t{2};
150 return a * p.x() +
b * p.y() +
c * p.z();
171 const auto ab =
b -
a;
172 const auto ca =
a -
c;
173 const auto ap = p -
a;
179 uvw.
x() = T{1} - uvw.
y() - uvw.
z();
210 const T xx_yy = p.x() * p.x() + p.y() * p.y();
216 std::atan2(p.y(), p.x())
232 const T x = p.x() * std::cos(p.y());
238 p.x() * std::sin(p.y())
constexpr bool is_edge_region(triangle_region region) noexcept
Checks whether a triangle voronoi region is an edge region.
point< T, 3 > spherical_to_cartesian(const point< T, 3 > &p)
Converts spherical coordinates to Cartesian (rectangular) coordinates.
constexpr std::uint8_t vertex_index(triangle_region region) noexcept
Returns the vertex index of a vertex region.
constexpr point< T, 3 > barycentric_to_cartesian(const point< T, 3 > &p, const point< T, 3 > &a, const point< T, 3 > &b, const point< T, 3 > &c) noexcept
Converts Cartesian coordinates to barycentric coordinates.
point< T, 3 > cartesian_to_spherical(const point< T, 3 > &p)
Converts Cartesian (rectangular) coordinates to spherical coordinates.
constexpr bool is_face_region(triangle_region region) noexcept
Checks whether a triangle voronoi region is a face region.
triangle_region
Voronoi regions of a triangle.
constexpr point< T, 3 > cartesian_to_barycentric(const point< T, 3 > &p, const point< T, 3 > &a, const point< T, 3 > &b, const point< T, 3 > &c) noexcept
Converts Cartesian coordinates to barycentric coordinates.
constexpr bool is_vertex_region(triangle_region region) noexcept
Checks whether a triangle voronoi region is a vertex region.
constexpr triangle_region barycentric_to_region(const point< T, 3 > &p) noexcept
Classifies barycentric coordinates according to their Voronoi region.
constexpr std::uint8_t edge_index(triangle_region region) noexcept
Returns the edge index of an edge region.
constexpr T sqr_length(const quaternion< T > &q) noexcept
Calculates the square length of a quaternion.
constexpr vector< T, 3 > cross(const vector< T, 3 > &x, const vector< T, 3 > &y) noexcept
Calculates the cross product of two vectors.
vector< T, N > sqrt(const vector< T, N > &x)
Takes the square root of each element.
constexpr T dot(const quaternion< T > &a, const quaternion< T > &b) noexcept
Calculates the dot product of two quaternions.
constexpr element_type & x() noexcept
Returns a reference to the first element.
constexpr element_type & y() noexcept
Returns a reference to the second element.
constexpr element_type & z() noexcept
Returns a reference to the third element.