25 #ifndef HERMES_GEOMETRY_PLANE_H
26 #define HERMES_GEOMETRY_PLANE_H
30 #include <hermes/geometry/surface.h>
57 static Plane XY(
bool invert_normal =
false) {
58 return {
normal3(0, 0, invert_normal ? -1 : 1), 0};
62 static Plane XZ(
bool invert_normal =
false) {
63 return {
normal3(0, invert_normal ? -1 : 1, 0), 0};
67 static Plane YZ(
bool invert_normal =
false) {
69 normal3(invert_normal ? -1 : 1, 0, 0), 0};
72 [[nodiscard]]
point3 closestPoint(
const point3 &p)
const {
74 return p - t *
vec3(normal);
86 [[nodiscard]]
bool onNormalSide(
const point3 &p)
const {
87 return dot(
vec3(normal), p - closestPoint(p)) >= 0;
90 friend std::ostream &operator<<(std::ostream &os,
const Plane &p) {
91 os <<
"[Plane] offset " << p.offset <<
" " << p.normal;
127 [[nodiscard]]
point2 closestPoint(
const point2 &p)
const override {
129 return p - t *
vec2(normal);
131 [[nodiscard]] normal2 closestNormal(
const point2 &p)
const override {
132 if (dot(vec2(normal), vec2(p)) < 0.f)
136 [[nodiscard]] bbox2 boundingBox()
const override {
return bbox2(); }
137 void closestIntersection(
const Ray2 &r,
138 CurveRayIntersection *i)
const override {
142 [[nodiscard]]
double signedDistance(
const point2 &p)
const override {
143 return (
dot(vec2(p), vec2(normal)) - offset) / vec2(normal).
length();
146 friend std::ostream &operator<<(std::ostream &os,
const ImplicitPlane2D &p) {
147 os <<
"[Plane] offset " << p.offset <<
" " << p.normal;
vec2 reflect(const vec2 &v) const
reflects v fron plane
Definition: plane.h:126
ImplicitPlane2D(normal2 n, real_t o)
Definition: plane.h:109
vec2 project(const vec2 &v) const
projects v on plane
Definition: plane.h:121
ImplicitPlane2D()
default_color constructor
Definition: plane.h:104
Plane(normal3 n, real_t o)
Definition: plane.h:47
vec3 project(const vec3 &v) const
projects v on plane
Definition: plane.h:80
static Plane XY(bool invert_normal=false)
Definition: plane.h:57
vec3 reflect(const vec3 &v) const
reflects v fron plane
Definition: plane.h:85
static Plane XZ(bool invert_normal=false)
Definition: plane.h:62
Plane()
default_color constructor
Definition: plane.h:42
static Plane YZ(bool invert_normal=false)
Definition: plane.h:67
HERMES_DEVICE_CALLABLE T length2() const
Computes squared magnitude.
Definition: vector.h:129
HERMES_DEVICE_CALLABLE T length() const
Computes magnitude.
Definition: vector.h:132
HERMES_DEVICE_CALLABLE T length2() const
Computes vector squared magnitude.
Definition: vector.h:326
#define HERMES_UNUSED_VARIABLE(x)
Specifies that variable is not used in this scope.
Definition: debug.h:62
float real_t
default floating point type
Definition: defs.h:75
Geometric normal classes.
HERMES_DEVICE_CALLABLE Vector2< T > project(const Vector2< T > &v, const Normal2< T > &n)
projects v on the surface with normal n
Definition: normal.h:193
HERMES_DEVICE_CALLABLE T dot(const Normal3< T > &n, const Vector3< T > &v)
Computes dot product with vector.
Definition: normal.h:237
HERMES_DEVICE_CALLABLE Vector2< T > reflect(const Vector2< T > &a, const Normal2< T > &n)
reflects a on n
Definition: normal.h:185
Geometric vector classes.