Plane.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_PLANE_HPP
12 #define CUBBYFLOW_PLANE_HPP
13 
15 
16 namespace CubbyFlow
17 {
24 template <size_t N>
25 class Plane final : public Surface<N>
26 {
27  public:
28  class Builder;
29 
32  Plane(const Transform<N>& _transform = Transform<N>{},
33  bool _isNormalFlipped = false);
34 
37  const Transform<N>& _transform = Transform<N>{},
38  bool _isNormalFlipped = false);
39 
41  ~Plane() override = default;
42 
44  Plane(const Plane& other);
45 
47  Plane(Plane&& other) noexcept;
48 
50  Plane& operator=(const Plane& other);
51 
53  Plane& operator=(Plane&& other) noexcept;
54 
56  [[nodiscard]] bool IsBounded() const override;
57 
59  static Builder GetBuilder();
60 
63 
66 
67  private:
68  [[nodiscard]] Vector<double, N> ClosestPointLocal(
69  const Vector<double, N>& otherPoint) const override;
70 
71  [[nodiscard]] bool IntersectsLocal(
72  const Ray<double, N>& ray) const override;
73 
74  [[nodiscard]] BoundingBox<double, N> BoundingBoxLocal() const override;
75 
76  [[nodiscard]] Vector<double, N> ClosestNormalLocal(
77  const Vector<double, N>& otherPoint) const override;
78 
79  [[nodiscard]] SurfaceRayIntersection<N> ClosestIntersectionLocal(
80  const Ray<double, N>& ray) const override;
81 };
82 
84 using Plane2 = Plane<2>;
85 
87 using Plane3 = Plane<3>;
88 
90 using Plane2Ptr = std::shared_ptr<Plane2>;
91 
93 using Plane3Ptr = std::shared_ptr<Plane3>;
94 
98 template <size_t N>
99 class Plane<N>::Builder final
100  : public SurfaceBuilderBase<N, typename Plane<N>::Builder>
101 {
102  public:
104  Builder& WithNormal(const Vector<double, N>& _normal);
105 
107  Builder& WithPoint(const Vector<double, N>& _point);
108 
110  Plane Build() const;
111 
113  std::shared_ptr<Plane<N>> MakeShared() const;
114 
115  private:
117  using Base::m_isNormalFlipped;
118  using Base::m_transform;
119 
121  Vector<double, N> m_point;
122 };
123 } // namespace CubbyFlow
124 
125 #endif
Class for N-D ray.
Definition: Ray.hpp:25
std::shared_ptr< Plane3 > Plane3Ptr
Shared pointer for the Plane3 type.
Definition: Plane.hpp:93
N-D plane geometry.
Definition: Plane.hpp:25
Plane(const Transform< N > &_transform=Transform< N >{}, bool _isNormalFlipped=false)
Vector< double, N > point
Point that lies on the plane.
Definition: Plane.hpp:65
Vector< double, N > normal
Plane normal.
Definition: Plane.hpp:62
Represents N-D rigid body transform.
Definition: Transform.hpp:82
Definition: Matrix.hpp:27
Definition: pybind11Utils.hpp:20
static Builder GetBuilder()
Returns builder fox Plane.
Abstract base class for N-D surface.
Definition: Surface.hpp:38
Struct that represents ray-surface intersection point.
Definition: Surface.hpp:25
std::shared_ptr< Plane2 > Plane2Ptr
Shared pointer for the Plane2 type.
Definition: Plane.hpp:90
bool IsBounded() const override
Returns true if bounding box can be defined.
Plane & operator=(const Plane &other)
Copy assignment operator.
Front-end to create Plane objects step by step.
Definition: Plane.hpp:99
Base class for N-D surface builder.
Definition: Surface.hpp:153
~Plane() override=default
Default virtual destructor.