10 #ifndef INCLUDED_ATOMSMATHPLANE_H
11 #define INCLUDED_ATOMSMATHPLANE_H
13 #include <AtomsMath/ImathLine.h>
14 #include <AtomsMath/ImathNamespace.h>
15 #include <AtomsMath/ImathVec.h>
17 ATOMSMATH_INTERNAL_NAMESPACE_HEADER_ENTER
48 ATOMSMATH_HOSTDEVICE
Plane3() noexcept {}
57 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Plane3 (
const Vec3<T>& point1,
59 const Vec3<T>& point3) noexcept;
84 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool
91 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
bool intersectT (
const Line3<T>& line, T& parameter)
const noexcept;
94 ATOMSMATH_HOSTDEVICE constexpr T
distanceTo (
const Vec3<T>& point)
const noexcept;
135 normal = (point2 - point1) % (point3 - point1);
137 distance = normal ^ point1;
146 distance = normal ^ point;
162 return (point ^ normal) - distance;
169 return normal * distanceTo (point) * -2.0 + point;
176 return normal * (normal ^ v) * 2.0 - v;
180 ATOMSMATH_CONSTEXPR14
inline bool
183 T d = normal ^ line.dir;
186 T t = -((normal ^ line.pos) - distance) / d;
192 ATOMSMATH_CONSTEXPR14
inline bool
195 T d = normal ^ line.dir;
198 t = -((normal ^ line.pos) - distance) / d;
205 operator<< (std::ostream& o,
const Plane3<T>& plane)
221 T dir1Len = dir1 ^ dir1;
224 T tmpLen = tmp ^ tmp;
226 if (tmpLen > dir1Len)
232 tmp =
Vec3<T> (0, 0, 1) % plane.normal;
235 if (tmpLen > dir1Len)
240 Vec3<T> dir2 = dir1 % plane.normal;
241 Vec3<T> point = plane.distance * plane.normal;
243 return Plane3<T> (point * M, (point + dir2) * M, (point + dir1) * M);
249 operator- (
const Plane3<T>& plane) noexcept
251 return Plane3<T> (-plane.normal, -plane.distance);
254 ATOMSMATH_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImathLine.h:25
Definition: ImathMatrix.h:631
Definition: ImathPlane.h:30
ATOMSMATH_HOSTDEVICE void set(const Vec3< T > &normal, T distance) noexcept
Set via a given normal and distance.
Definition: ImathPlane.h:151
ATOMSMATH_HOSTDEVICE Plane3() noexcept
Uninitialized by default.
Definition: ImathPlane.h:48
T distance
The distance from the origin to the plane.
Definition: ImathPlane.h:40
constexpr ATOMSMATH_HOSTDEVICE T distanceTo(const Vec3< T > &point) const noexcept
Return the distance from a point to the plane.
Definition: ImathPlane.h:160
constexpr ATOMSMATH_HOSTDEVICE Vec3< T > reflectPoint(const Vec3< T > &point) const noexcept
Reflect the given point around the plane.
Definition: ImathPlane.h:167
Vec3< T > normal
The normal to the plane.
Definition: ImathPlane.h:37
constexpr ATOMSMATH_HOSTDEVICE Vec3< T > reflectVector(const Vec3< T > &vec) const noexcept
Reflect the direction vector around the plane.
Definition: ImathPlane.h:174
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool intersectT(const Line3< T > &line, T ¶meter) const noexcept
Definition: ImathPlane.h:193
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool intersect(const Line3< T > &line, Vec3< T > &intersection) const noexcept
Definition: ImathPlane.h:181
Definition: ImathVec.h:260