Line3 Functions¶
#include <Imath/ImathLineAlgo.h>
Functions that operate on the Line3
object.
-
template<class T>
constexpr bool Imath::closestPoints(const Line3<T> &line1, const Line3<T> &line2, Vec3<T> &point1, Vec3<T> &point2) noexcept¶ Compute point1 and point2 such that point1 is on line1, point2 is on line2 and the distance between point1 and point2 is minimal.
This function returns true if point1 and point2 can be computed, or false if line1 and line2 are parallel or nearly parallel. This function assumes that line1.dir and line2.dir are normalized.
-
template<class T>
constexpr bool Imath::intersect(const Line3<T> &line, const Vec3<T> &v0, const Vec3<T> &v1, const Vec3<T> &v2, Vec3<T> &pt, Vec3<T> &barycentric, bool &front) noexcept¶ Given a line and a triangle (v0, v1, v2), the intersect() function finds the intersection of the line and the plane that contains the triangle.
If the intersection point cannot be computed, either because the line and the triangle’s plane are nearly parallel or because the triangle’s area is very small, intersect() returns false.
If the intersection point is outside the triangle, intersect returns false.
If the intersection point, pt, is inside the triangle, intersect() computes a front-facing flag and the barycentric coordinates of the intersection point, and returns true.
The front-facing flag is true if the dot product of the triangle’s normal, (v2-v1)%(v1-v0), and the line’s direction is negative.
The barycentric coordinates have the following property:
pt = v0 * barycentric.x + v1 * barycentric.y + v2 * barycentric.z