Loading...
Searching...
No Matches
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
16namespace CubbyFlow
17{
24template <size_t N>
25class Plane final : public Surface<N>
26{
27 public:
28 class Builder;
29
33 {
34 // Do nothing
35 }
36
38 explicit Plane(const Transform<N>& _transform,
39 bool _isNormalFlipped = false);
40
43 const Transform<N>& _transform = Transform<N>{},
44 bool _isNormalFlipped = false);
45
47 ~Plane() override = default;
48
50 Plane(const Plane& other);
51
53 Plane(Plane&& other) noexcept;
54
56 Plane& operator=(const Plane& other);
57
59 Plane& operator=(Plane&& other) noexcept;
60
62 [[nodiscard]] bool IsBounded() const override;
63
66
69
72
73 private:
74 [[nodiscard]] Vector<double, N> ClosestPointLocal(
75 const Vector<double, N>& otherPoint) const override;
76
77 [[nodiscard]] bool IntersectsLocal(
78 const Ray<double, N>& ray) const override;
79
80 [[nodiscard]] BoundingBox<double, N> BoundingBoxLocal() const override;
81
82 [[nodiscard]] Vector<double, N> ClosestNormalLocal(
83 const Vector<double, N>& otherPoint) const override;
84
85 [[nodiscard]] SurfaceRayIntersection<N> ClosestIntersectionLocal(
86 const Ray<double, N>& ray) const override;
87};
88
91
94
96using Plane2Ptr = std::shared_ptr<Plane2>;
97
99using Plane3Ptr = std::shared_ptr<Plane3>;
100
104template <size_t N>
105class Plane<N>::Builder final
106 : public SurfaceBuilderBase<N, typename Plane<N>::Builder>
107{
108 public:
111
114
116 Plane Build() const;
117
119 std::shared_ptr<Plane<N>> MakeShared() const;
120
121 private:
123 using Base::m_isNormalFlipped;
124 using Base::m_transform;
125
127 Vector<double, N> m_point;
128};
129} // namespace CubbyFlow
130
131#endif
N-D axis-aligned bounding box class.
Definition BoundingBox.hpp:47
Definition Matrix.hpp:30
Front-end to create Plane objects step by step.
Definition Plane.hpp:107
Builder & WithNormal(const Vector< double, N > &_normal)
Returns builder with plane normal.
Plane Build() const
Builds Plane.
Builder & WithPoint(const Vector< double, N > &_point)
Returns builder with point on the plane.
std::shared_ptr< Plane< N > > MakeShared() const
Builds shared pointer of Plane instance.
N-D plane geometry.
Definition Plane.hpp:26
Plane()
Definition Plane.hpp:32
Plane(Plane &&other) noexcept
Move constructor.
~Plane() override=default
Default virtual destructor.
bool IsBounded() const override
Returns true if bounding box can be defined.
Plane & operator=(const Plane &other)
Copy assignment operator.
Plane(const Plane &other)
Copy constructor.
Vector< double, N > normal
Plane normal.
Definition Plane.hpp:68
static Builder GetBuilder()
Returns builder fox Plane.
Vector< double, N > point
Point that lies on the plane.
Definition Plane.hpp:71
Plane(const Transform< N > &_transform, bool _isNormalFlipped=false)
Constructs a default plane with a transform.
Plane(const Vector< double, N > &normal, const Vector< double, N > &point, const Transform< N > &_transform=Transform< N >{}, bool _isNormalFlipped=false)
Constructs a plane that cross point with surface normal normal.
Plane & operator=(Plane &&other) noexcept
Move assignment operator.
Class for N-D ray.
Definition Ray.hpp:26
Base class for N-D surface builder.
Definition Surface.hpp:154
Abstract base class for N-D surface.
Definition Surface.hpp:39
Represents N-D rigid body transform.
Definition Transform.hpp:83
Definition pybind11Utils.hpp:22
std::shared_ptr< Plane3 > Plane3Ptr
Shared pointer for the Plane3 type.
Definition Plane.hpp:99
std::shared_ptr< Plane2 > Plane2Ptr
Shared pointer for the Plane2 type.
Definition Plane.hpp:96
Struct that represents ray-surface intersection point.
Definition Surface.hpp:26