HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImathLineAlgo.h File Reference
#include "ImathFun.h"
#include "ImathLine.h"
#include "ImathNamespace.h"
#include "ImathVecAlgo.h"
+ Include dependency graph for ImathLineAlgo.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<class T >
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER
IMATH_CONSTEXPR14 bool 
closestPoints (const Line3< T > &line1, const Line3< T > &line2, Vec3< T > &point1, Vec3< T > &point2) IMATH_NOEXCEPT
 
template<class T >
IMATH_CONSTEXPR14 bool 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) IMATH_NOEXCEPT
 
template<class T >
IMATH_CONSTEXPR14 Vec3< T > closestVertex (const Vec3< T > &v0, const Vec3< T > &v1, const Vec3< T > &v2, const Line3< T > &l) IMATH_NOEXCEPT
 
template<class T >
IMATH_CONSTEXPR14 Vec3< T > rotatePoint (const Vec3< T > p, Line3< T > l, T angle) IMATH_NOEXCEPT
 

Function Documentation

template<class T >
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_CONSTEXPR14 bool closestPoints ( const Line3< T > &  line1,
const Line3< T > &  line2,
Vec3< T > &  point1,
Vec3< T > &  point2 
)

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.

Definition at line 31 of file ImathLineAlgo.h.

template<class T >
IMATH_CONSTEXPR14 Vec3<T> closestVertex ( const Vec3< T > &  v0,
const Vec3< T > &  v1,
const Vec3< T > &  v2,
const Line3< T > &  l 
)

Return the vertex that is closest to the given line. The returned point is either v0, v1, or v2.

Definition at line 164 of file ImathLineAlgo.h.

template<class T >
IMATH_CONSTEXPR14 bool 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 
)

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
Examples:
karma_procedurals/BRAY_HdSphere.C.

Definition at line 80 of file ImathLineAlgo.h.

template<class T >
IMATH_CONSTEXPR14 Vec3<T> rotatePoint ( const Vec3< T >  p,
Line3< T >  l,
angle 
)

Rotate the point p around the line l by the given angle.

Definition at line 193 of file ImathLineAlgo.h.