10#ifndef MATH_GEOMETRY_HEADER
11#define MATH_GEOMETRY_HEADER
142 ret = a + ret / (ba.
dot(x3) * T(2));
158 T vol6 = std::abs(ba.
dot(ca.
cross(da)));
160 + da.
dot(da) * ba.
cross(ca)).norm() / (vol6 * T(2));
174 T vol6 = std::abs(va.
dot(vb.
cross(vc)));
175 return vol6 / (vb.
cross(vc).norm() + vc.
cross(va).norm()
176 + va.
cross(vb).norm()
197 T denom = ba.
dot(x3) * T(2);
199 T square_radius = num.
square_norm() / (denom * denom);
200 T point_sdist = (p - (a + num / denom)).square_norm();
201 return square_radius - point_sdist;
211 return (b - a).cross(c - a).norm() / T(2);
226 return (c - a).dot((b - a).cross(d - c)) / T(6);
231 for (
int i = 0; i < 9; ++i)
232 m[i] = v[i % 3][i / 3];
245 return (c - a).dot((b - a).cross(d - c));
267 for (
int i = 0; i < 9; ++i)
268 m[i] = v[i % 3][i / 3];
295 return x <= cos_angle;
Matrix class for arbitrary dimensions and types.
Vector class for arbitrary dimensions and types.
T square_norm(void) const
Computes the squared norm of the vector (much cheaper).
Vector< T, N > cross(Vector< T, N > const &other) const
Cross product between this and another vector.
T dot(Vector< T, N > const &other) const
Dot (or scalar) product between self and another vector.
Vector< T, N > normalized(void) const
Returns a normalized copy of self.
#define MATH_GEOM_NAMESPACE_BEGIN
#define MATH_NAMESPACE_BEGIN
#define MATH_NAMESPACE_END
#define MATH_GEOM_NAMESPACE_END
bool points_coplanar(math::Vector< T, 3 > const &a, math::Vector< T, 3 > const &b, math::Vector< T, 3 > const &c, math::Vector< T, 3 > const &d, T const &cos_angle)
Tests whether four points are coplanar.
T tetrahedron_orientation(math::Vector< T, 3 > const &a, math::Vector< T, 3 > const &b, math::Vector< T, 3 > const &c, math::Vector< T, 3 > const &d)
Calculates the orientation of the given tetrahedron.
math::Vector< T, 3 > tetrahedron_bary(math::Vector< T, 3 > const &a, math::Vector< T, 3 > const &b, math::Vector< T, 3 > const &c, math::Vector< T, 3 > const &d, math::Vector< T, 3 > const &p)
Calculates the barycentric coordinates of point 'p' with respect to the tetrahedron given by vertices...
float circumsphere_radius(math::Vector< T, 3 > const &a, math::Vector< T, 3 > const &b, math::Vector< T, 3 > const &c, math::Vector< T, 3 > const &d)
Returns the circumsphere radius of the sphere defined by a, b, c, d.
T triangle_area(math::Vector< T, 3 > const &a, math::Vector< T, 3 > const &b, math::Vector< T, 3 > const &c)
Calculates the area of the given triangle.
float circumsphere_test(math::Vector< T, 3 > const &a, math::Vector< T, 3 > const &b, math::Vector< T, 3 > const &c, math::Vector< T, 3 > const &d, math::Vector< T, 3 > const &p)
Tests whether vertex 'p' is contained in the circumsphere defined by the four vertices a,...
T tetrahedron_volume(math::Vector< T, 3 > const &a, math::Vector< T, 3 > const &b, math::Vector< T, 3 > const &c, math::Vector< T, 3 > const &d)
Calculates the volume of the given tetraheron.
float insphere_radius(math::Vector< T, 3 > const &a, math::Vector< T, 3 > const &b, math::Vector< T, 3 > const &c, math::Vector< T, 3 > const &d)
Returns the insphere radius of the tetrahedron defined by a, b, c, d.
math::Vector< T, 3 > circumsphere_center(math::Vector< T, 3 > const &a, math::Vector< T, 3 > const &b, math::Vector< T, 3 > const &c, math::Vector< T, 3 > const &d)
Returns the center of the circumsphere defined by the four given vertices.
Matrix< T, N, N > matrix_inverse(Matrix< T, N, N > const &mat)
Calculates the inverse of the given matrix.
T matrix_determinant(Matrix< T, N, N > const &mat)
Calculates the determinant of the given matrix.