10 #ifndef INCLUDED_ATOMSMATHLINE_H
11 #define INCLUDED_ATOMSMATHLINE_H
13 #include <AtomsMath/ImathMatrix.h>
14 #include <AtomsMath/ImathNamespace.h>
15 #include <AtomsMath/ImathVec.h>
17 ATOMSMATH_INTERNAL_NAMESPACE_HEADER_ENTER
43 ATOMSMATH_HOSTDEVICE constexpr
Line3() noexcept {}
47 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Line3 (
const Vec3<T>& point1,
const Vec3<T>& point2) noexcept;
56 ATOMSMATH_HOSTDEVICE
void set (
const Vec3<T>& point1,
const Vec3<T>& point2) noexcept;
68 ATOMSMATH_HOSTDEVICE constexpr T
distanceTo (
const Vec3<T>& point)
const noexcept;
70 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T
distanceTo (
const Line3<T>& line)
const noexcept;
105 return pos + dir * parameter;
112 return (closestPointTo (point) - point).length();
119 return ((point - pos) ^ dir) * dir + pos;
123 ATOMSMATH_CONSTEXPR14
inline T
126 T d = (dir % line.dir) ^ (line.pos - pos);
127 return (d >= 0) ? d : -d;
131 ATOMSMATH_CONSTEXPR14
inline Vec3<T>
136 Vec3<T> posLpos = pos - line.pos;
138 T a = line.dir ^ dir;
139 T f = line.dir ^ posLpos;
144 T absDenom = ((denom >= 0) ? denom : -denom);
148 T absNum = ((num >= 0) ? num : -num);
150 if (absNum >= absDenom * std::numeric_limits<T>::max())
154 return pos + dir * (num / denom);
160 operator<< (std::ostream& o,
const Line3<T>& line)
162 return o <<
"(" << line.
pos <<
", " << line.
dir <<
")";
166 template <
class S,
class T>
170 return Line3<S> (line.pos * M, (line.pos + line.dir) * M);
197 ATOMSMATH_HOSTDEVICE constexpr
Line2() noexcept {}
201 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Line2(
const Vec2<T>& point1,
const Vec2<T>& point2) noexcept;
210 ATOMSMATH_HOSTDEVICE
void set(
const Vec2<T>& point1,
const Vec2<T>& point2) noexcept;
247 return pos + dir * parameter;
254 T t = dir.dot(point - pos);
255 return operator()(t);
258 ATOMSMATH_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImathLine.h:180
constexpr ATOMSMATH_HOSTDEVICE Vec2< T > closestPointTo(const Vec2< T > &point) const noexcept
Return the point on the line closest to the given point.
Definition: ImathLine.h:252
Vec2< T > pos
A point on the line.
Definition: ImathLine.h:187
ATOMSMATH_HOSTDEVICE void set(const Vec2< T > &point1, const Vec2< T > &point2) noexcept
Definition: ImathLine.h:236
constexpr ATOMSMATH_HOSTDEVICE Line2() noexcept
Uninitialized by default.
Definition: ImathLine.h:197
Vec2< T > dir
The direction of the line.
Definition: ImathLine.h:190
constexpr ATOMSMATH_HOSTDEVICE Vec2< T > operator()(T parameter) const noexcept
Definition: ImathLine.h:245
Definition: ImathLine.h:25
constexpr ATOMSMATH_HOSTDEVICE Vec3< T > operator()(T parameter) const noexcept
Definition: ImathLine.h:103
constexpr ATOMSMATH_HOSTDEVICE T distanceTo(const Vec3< T > &point) const noexcept
Return the distance to the given point.
Definition: ImathLine.h:110
ATOMSMATH_HOSTDEVICE void set(const Vec3< T > &point1, const Vec3< T > &point2) noexcept
Definition: ImathLine.h:94
constexpr ATOMSMATH_HOSTDEVICE Line3() noexcept
Uninitialized by default.
Definition: ImathLine.h:43
Vec3< T > pos
A point on the line.
Definition: ImathLine.h:32
constexpr ATOMSMATH_HOSTDEVICE Vec3< T > closestPointTo(const Vec3< T > &point) const noexcept
Return the point on the line closest to the given point.
Definition: ImathLine.h:117
Vec3< T > dir
The direction of the line.
Definition: ImathLine.h:35
Definition: ImathMatrix.h:631
Definition: ImathVec.h:43
Definition: ImathVec.h:260