Plane3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: Plane3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-D plane geometry.
6 > Created Time: 2017/06/18
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_PLANE3_H
10 #define CUBBYFLOW_PLANE3_H
11 
12 #include <Core/Surface/Surface3.h>
13 
14 namespace CubbyFlow
15 {
22  class Plane3 final : public Surface3
23  {
24  public:
25  class Builder;
26 
28  Vector3D normal = Vector3D(0, 1, 0);
29 
32 
34  Plane3(const Transform3& transform = Transform3(), bool isNormalFlipped = false);
35 
37  Plane3(const Vector3D& normal, const Vector3D& point,
38  const Transform3& transform = Transform3(), bool isNormalFlipped = false);
39 
42  Plane3(const Vector3D& point0, const Vector3D& point1, const Vector3D& point2,
43  const Transform3& transform = Transform3(), bool isNormalFlipped = false);
44 
46  Plane3(const Plane3& other);
47 
49  static Builder GetBuilder();
50 
51  protected:
52  Vector3D ClosestPointLocal(const Vector3D& otherPoint) const override;
53 
54  bool IntersectsLocal(const Ray3D& ray) const override;
55 
56  BoundingBox3D BoundingBoxLocal() const override;
57 
58  Vector3D ClosestNormalLocal(const Vector3D& otherPoint) const override;
59 
60  SurfaceRayIntersection3 ClosestIntersectionLocal(const Ray3D& ray) const override;
61  };
62 
64  using Plane3Ptr = std::shared_ptr<Plane3>;
65 
69  class Plane3::Builder final : public SurfaceBuilderBase3<Plane3::Builder>
70  {
71  public:
74 
77 
79  Plane3 Build() const;
80 
82  Plane3Ptr MakeShared() const;
83 
84  private:
85  Vector3D m_normal{ 0, 1, 0 };
86  Vector3D m_point{ 0, 0, 0 };
87  };
88 }
89 
90 #endif
3-D vector class.
Definition: Vector3.h:26
Vector3D point
Point that lies on the plane.
Definition: Plane3.h:31
std::shared_ptr< Plane3 > Plane3Ptr
Shared pointer for the Plane3 type.
Definition: Plane3.h:64
static Builder GetBuilder()
Returns builder fox Plane3.
Plane3 Build() const
Builds Plane3.
BoundingBox3D BoundingBoxLocal() const override
Returns the bounding box of this surface object in local frame.
Builder & WithNormal(const Vector3D &normal)
Returns builder with plane normal.
Structure that represents ray-surface intersection point.
Definition: Surface3.h:23
Vector3D ClosestPointLocal(const Vector3D &otherPoint) const override
Builder & WithPoint(const Vector3D &point)
Returns builder with point on the plane.
Base class for 3-D surface builder.
Definition: Surface3.h:106
Definition: pybind11Utils.h:24
Front-end to create Plane3 objects step by step.
Definition: Plane3.h:69
Abstract base class for 3-D surface.
Definition: Surface3.h:32
Transform3 transform
Local-to-world transform.
Definition: Surface3.h:36
Plane3(const Transform3 &transform=Transform3(), bool isNormalFlipped=false)
Constructs a plane that crosses (0, 0, 0) with surface normal (0, 1, 0).
3-D axis-aligned bounding box class.
Definition: BoundingBox3.h:44
Vector3D normal
Plane normal.
Definition: Plane3.h:28
bool IntersectsLocal(const Ray3D &ray) const override
Represents 3-D rigid body transform.
Definition: Transform3.h:22
bool isNormalFlipped
Flips normal when calling Surface3::closestNormal(...).
Definition: Surface3.h:39
Vector3D ClosestNormalLocal(const Vector3D &otherPoint) const override
3-D plane geometry.
Definition: Plane3.h:22
Class for 3-D ray.
Definition: Ray3.h:23
SurfaceRayIntersection3 ClosestIntersectionLocal(const Ray3D &ray) const override
Returns the closest intersection point for given ray in local frame.
Plane3Ptr MakeShared() const
Builds shared pointer of Plane3 instance.
Vector3< double > Vector3D
Double-type 3D vector.
Definition: Vector3.h:353