24#ifndef JAU_GEOM3F_HPP_
25#define JAU_GEOM3F_HPP_
66 if( 0 == determinant ) {
71 const float xi = ((o.
p0.
x-o.
p1.
x)*alpha-(
p0.
x-
p1.
x)*beta)/determinant;
73 const float gamma0 = (xi -
p0.
x) / (
p1.
x -
p0.
x);
74 const float gamma1 = (xi - o.
p0.
x) / (o.
p1.
x - o.
p0.
x);
75 if(gamma0 <= 0 || gamma0 >= 1 || gamma1 <= 0 || gamma1 >= 1) {
78 const float yi = ((o.
p0.
y-o.
p1.
y)*alpha-(
p0.
y-
p1.
y)*beta)/determinant;
94 if( 0 == determinant ) {
99 const float xi = ((o.
p0.
x-o.
p1.
x)*alpha-(
p0.
x-
p1.
x)*beta)/determinant;
101 const float gamma0 = (xi -
p0.
x) / (
p1.
x -
p0.
x);
102 const float gamma1 = (xi - o.
p0.
x) / (o.
p1.
x - o.
p0.
x);
103 if(gamma0 <= 0 || gamma0 >= 1 || gamma1 <= 0 || gamma1 >= 1) {
112 const Vec3f e = (box.tr - box.bl) * 0.5f;
113 const Vec3f aabb_center = (box.bl + box.tr) * 0.5f;
114 const Vec3f lseg_center =
p0 + d;
115 const Vec3f c = lseg_center - aabb_center;
123 if (
std::abs(d.
y * c.
z - d.
z * c.
y) > e.
y * ad.
z + e.
z * ad.
y + std::numeric_limits<float>::epsilon()) {
126 if (
std::abs(d.
z * c.
x - d.
x * c.
z) > e.
z * ad.
x + e.
x * ad.
z + std::numeric_limits<float>::epsilon()) {
129 if (
std::abs(d.
x * c.
y - d.
y * c.
x) > e.
x * ad.
y + e.
y * ad.
x + std::numeric_limits<float>::epsilon()) {
std::string toString() const noexcept
Axis Aligned Bounding Box.
constexpr T abs(const T x) noexcept
Returns the absolute value of an arithmetic number (w/ branching) in O(1)
bool intersects(const AABBox3f &box) const noexcept
constexpr LineSeg3f & operator*=(const float s) noexcept
Scale this line segment with given scale factor.
bool intersects(Point3f &result, const LineSeg3f &o)
Compute intersection between two lines segments.
std::string toString() const noexcept
bool intersects(const LineSeg3f &o)
Compute intersection between two lines segments.