Jet  v1.3.3
cylinder3.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_CYLINDER3_H_
8 #define INCLUDE_JET_CYLINDER3_H_
9 
10 #include <jet/surface3.h>
11 
12 namespace jet {
13 
20 class Cylinder3 final : public Surface3 {
21  public:
22  class Builder;
23 
26 
28  double radius = 1.0;
29 
31  double height = 1.0;
32 
35  const Transform3& transform = Transform3(),
36  bool isNormalFlipped = false);
37 
40  const Vector3D& center,
41  double radius,
42  double height,
43  const Transform3& transform = Transform3(),
44  bool isNormalFlipped = false);
45 
47  Cylinder3(const Cylinder3& other);
48 
50  static Builder builder();
51 
52  protected:
53  // Surface3 implementations
54 
55  Vector3D closestPointLocal(const Vector3D& otherPoint) const override;
56 
57  double closestDistanceLocal(const Vector3D& otherPoint) const override;
58 
59  bool intersectsLocal(const Ray3D& ray) const override;
60 
61  BoundingBox3D boundingBoxLocal() const override;
62 
63  Vector3D closestNormalLocal(const Vector3D& otherPoint) const override;
64 
66  const Ray3D& ray) const override;
67 };
68 
70 typedef std::shared_ptr<Cylinder3> Cylinder3Ptr;
71 
72 
76 class Cylinder3::Builder final
77  : public SurfaceBuilderBase3<Cylinder3::Builder> {
78  public:
81 
84 
87 
89  Cylinder3 build() const;
90 
93 
94  private:
95  Vector3D _center{0, 0, 0};
96  double _radius = 1.0;
97  double _height = 1.0;
98 };
99 
100 } // namespace jet
101 
102 
103 #endif // INCLUDE_JET_CYLINDER3_H_
jet::Cylinder3::closestPointLocal
Vector3D closestPointLocal(const Vector3D &otherPoint) const override
jet::Cylinder3::Cylinder3
Cylinder3(const Cylinder3 &other)
Copy constructor.
jet::Cylinder3::Builder
Front-end to create Cylinder3 objects step by step.
Definition: cylinder3.h:77
jet::Cylinder3Ptr
std::shared_ptr< Cylinder3 > Cylinder3Ptr
Shared pointer type for the Cylinder3.
Definition: cylinder3.h:70
jet::Cylinder3::boundingBoxLocal
BoundingBox3D boundingBoxLocal() const override
Returns the bounding box of this surface object in local frame.
jet::Cylinder3::Builder::makeShared
Cylinder3Ptr makeShared() const
Builds shared pointer of Cylinder3 instance.
surface3.h
jet::BoundingBox< T, 3 >
3-D axis-aligned bounding box class.
Definition: bounding_box3.h:41
jet::Cylinder3::closestDistanceLocal
double closestDistanceLocal(const Vector3D &otherPoint) const override
jet::Cylinder3::Builder::withCenter
Builder & withCenter(const Vector3D &center)
Returns builder with center.
jet::Cylinder3::Builder::withHeight
Builder & withHeight(double height)
Returns builder with height.
jet::SurfaceBuilderBase3
Base class for 3-D surface builder.
Definition: surface3.h:115
jet::Surface3::isNormalFlipped
bool isNormalFlipped
Flips normal when calling Surface3::closestNormal(...).
Definition: surface3.h:33
jet::Cylinder3
3-D cylinder geometry.
Definition: cylinder3.h:20
jet::Cylinder3::builder
static Builder builder()
Returns builder fox Cylinder3.
jet
Definition: advection_solver2.h:18
jet::Cylinder3::radius
double radius
Radius of the cylinder.
Definition: cylinder3.h:28
jet::Cylinder3::closestNormalLocal
Vector3D closestNormalLocal(const Vector3D &otherPoint) const override
jet::Cylinder3::Cylinder3
Cylinder3(const Vector3D &center, double radius, double height, const Transform3 &transform=Transform3(), bool isNormalFlipped=false)
Constructs a cylinder with center, radius, and height.
jet::Cylinder3::Cylinder3
Cylinder3(const Transform3 &transform=Transform3(), bool isNormalFlipped=false)
Constructs a cylinder with.
jet::Cylinder3::center
Vector3D center
Center of the cylinder.
Definition: cylinder3.h:22
jet::Surface3::transform
Transform3 transform
Local-to-world transform.
Definition: surface3.h:30
jet::Ray< T, 3 >
Class for 2-D ray.
Definition: ray3.h:21
jet::Cylinder3::Builder::build
Cylinder3 build() const
Builds Cylinder3.
jet::SurfaceRayIntersection3
Struct that represents ray-surface intersection point.
Definition: surface3.h:19
jet::Vector< T, 3 >
3-D vector class.
Definition: vector3.h:25
jet::Cylinder3::intersectsLocal
bool intersectsLocal(const Ray3D &ray) const override
jet::Transform3
Represents 3-D rigid body transform.
Definition: transform3.h:20
jet::Cylinder3::closestIntersectionLocal
SurfaceRayIntersection3 closestIntersectionLocal(const Ray3D &ray) const override
Returns the closest intersection point for given ray in local frame.
jet::Surface3
Abstract base class for 3-D surface.
Definition: surface3.h:27
jet::Cylinder3::height
double height
Height of the cylinder.
Definition: cylinder3.h:31
jet::Cylinder3::Builder::withRadius
Builder & withRadius(double radius)
Returns builder with radius.