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
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
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
85
88
90using Plane2Ptr = std::shared_ptr<Plane2>;
91
93using Plane3Ptr = std::shared_ptr<Plane3>;
94
98template <size_t N>
99class Plane<N>::Builder final
100 : public SurfaceBuilderBase<N, typename Plane<N>::Builder>
101{
102 public:
105
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
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:101
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(const Transform< N > &_transform=Transform< N >{}, bool _isNormalFlipped=false)
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:62
static Builder GetBuilder()
Returns builder fox Plane.
Vector< double, N > point
Point that lies on the plane.
Definition Plane.hpp:65
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:21
std::shared_ptr< Plane3 > Plane3Ptr
Shared pointer for the Plane3 type.
Definition Plane.hpp:93
std::shared_ptr< Plane2 > Plane2Ptr
Shared pointer for the Plane2 type.
Definition Plane.hpp:90
Struct that represents ray-surface intersection point.
Definition Surface.hpp:26