Cylinder3.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_CYLINDER3_HPP
12 #define CUBBYFLOW_CYLINDER3_HPP
13 
15 
16 namespace CubbyFlow
17 {
24 class Cylinder3 final : public Surface3
25 {
26  public:
27  class Builder;
28 
30  Cylinder3(const Transform3& _transform = Transform3{},
31  bool _isNormalFlipped = false);
32 
35  Cylinder3(Vector3D _center, double _radius, double _height,
36  const Transform3& _transform = Transform3{},
37  bool _isNormalFlipped = false);
38 
40  Cylinder3(const Cylinder3&) = default;
41 
43  Cylinder3(Cylinder3&&) noexcept = default;
44 
46  ~Cylinder3() override = default;
47 
49  Cylinder3& operator=(const Cylinder3&) = default;
50 
52  Cylinder3& operator=(Cylinder3&&) noexcept = default;
53 
55  [[nodiscard]] static Builder GetBuilder();
56 
59 
61  double radius = 1.0;
62 
64  double height = 1.0;
65 
66  protected:
67  [[nodiscard]] Vector3D ClosestPointLocal(
68  const Vector3D& otherPoint) const override;
69 
70  [[nodiscard]] double ClosestDistanceLocal(
71  const Vector3D& otherPoint) const override;
72 
73  [[nodiscard]] bool IntersectsLocal(const Ray3D& ray) const override;
74 
75  [[nodiscard]] BoundingBox3D BoundingBoxLocal() const override;
76 
77  [[nodiscard]] Vector3D ClosestNormalLocal(
78  const Vector3D& otherPoint) const override;
79 
81  const Ray3D& ray) const override;
82 };
83 
85 using Cylinder3Ptr = std::shared_ptr<Cylinder3>;
86 
90 class Cylinder3::Builder final : public SurfaceBuilderBase3<Builder>
91 {
92  public:
94  [[nodiscard]] Builder& WithCenter(const Vector3D& _center);
95 
97  [[nodiscard]] Builder& WithRadius(double _radius);
98 
100  [[nodiscard]] Builder& WithHeight(double _height);
101 
103  [[nodiscard]] Cylinder3 Build() const;
104 
106  [[nodiscard]] Cylinder3Ptr MakeShared() const;
107 
108  private:
109  Vector3D m_center{ 0, 0, 0 };
110  double m_radius = 1.0;
111  double m_height = 1.0;
112 };
113 } // namespace CubbyFlow
114 
115 #endif
static Builder GetBuilder()
Returns builder fox Cylinder3.
bool IntersectsLocal(const Ray3D &ray) const override
Class for N-D ray.
Definition: Ray.hpp:25
double height
Height of the cylinder.
Definition: Cylinder3.hpp:64
double radius
Radius of the cylinder.
Definition: Cylinder3.hpp:61
N-D axis-aligned bounding box class.
Definition: BoundingBox.hpp:46
~Cylinder3() override=default
Default virtual destructor.
Vector3D ClosestNormalLocal(const Vector3D &otherPoint) const override
3-D cylinder geometry.
Definition: Cylinder3.hpp:24
double ClosestDistanceLocal(const Vector3D &otherPoint) const override
Represents N-D rigid body transform.
Definition: Transform.hpp:82
Definition: Matrix.hpp:27
Definition: pybind11Utils.hpp:20
SurfaceRayIntersection3 ClosestIntersectionLocal(const Ray3D &ray) const override
Abstract base class for N-D surface.
Definition: Surface.hpp:38
Struct that represents ray-surface intersection point.
Definition: Surface.hpp:25
Cylinder3(const Transform3 &_transform=Transform3{}, bool _isNormalFlipped=false)
Constructs a cylinder with _transform and _isNormalFlipped.
Vector3D center
Center of the cylinder.
Definition: Cylinder3.hpp:58
Front-end to create Cylinder3 objects step by step.
Definition: Cylinder3.hpp:90
Vector3D ClosestPointLocal(const Vector3D &otherPoint) const override
Cylinder3 & operator=(const Cylinder3 &)=default
Default copy assignment operator.
BoundingBox3D BoundingBoxLocal() const override
Returns the bounding box of this surface object in local frame.
Base class for N-D surface builder.
Definition: Surface.hpp:153
std::shared_ptr< Cylinder3 > Cylinder3Ptr
Shared pointer type for the Cylinder3.
Definition: Cylinder3.hpp:85