Jet  v1.3.3
plane2.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_PLANE2_H_
8 #define INCLUDE_JET_PLANE2_H_
9 
10 #include <jet/surface2.h>
11 
12 namespace jet {
13 
20 class Plane2 final : public Surface2 {
21  public:
22  class Builder;
23 
26 
29 
32  const Transform2& transform = Transform2(),
33  bool isNormalFlipped = false);
34 
37  const Vector2D& normal,
38  const Vector2D& point,
39  const Transform2& transform = Transform2(),
40  bool isNormalFlipped = false);
41 
43  Plane2(const Plane2& other);
44 
46  bool isBounded() const override;
47 
49  static Builder builder();
50 
51  private:
52  Vector2D closestPointLocal(const Vector2D& otherPoint) const override;
53 
54  bool intersectsLocal(const Ray2D& ray) const override;
55 
56  BoundingBox2D boundingBoxLocal() const override;
57 
58  Vector2D closestNormalLocal(const Vector2D& otherPoint) const override;
59 
60  SurfaceRayIntersection2 closestIntersectionLocal(
61  const Ray2D& ray) const override;
62 };
63 
65 typedef std::shared_ptr<Plane2> Plane2Ptr;
66 
67 
71 class Plane2::Builder final : public SurfaceBuilderBase2<Plane2::Builder> {
72  public:
75 
78 
80  Plane2 build() const;
81 
84 
85  private:
86  Vector2D _normal{0, 1};
87  Vector2D _point{0, 0};
88 };
89 
90 } // namespace jet
91 
92 #endif // INCLUDE_JET_PLANE2_H_
surface2.h
jet::SurfaceRayIntersection2
Struct that represents ray-surface intersection point.
Definition: surface2.h:19
jet::Surface2::isNormalFlipped
bool isNormalFlipped
Flips normal.
Definition: surface2.h:33
jet::Plane2::Plane2
Plane2(const Transform2 &transform=Transform2(), bool isNormalFlipped=false)
Constructs a plane that crosses (0, 0) with surface normal (0, 1).
jet::Plane2::Plane2
Plane2(const Vector2D &normal, const Vector2D &point, const Transform2 &transform=Transform2(), bool isNormalFlipped=false)
Constructs a plane that cross point with surface normal normal.
jet::Transform2
Represents 2-D rigid body transform.
Definition: transform2.h:19
jet::Plane2::Builder::build
Plane2 build() const
Builds Plane2.
jet::Plane2::Builder::withNormal
Builder & withNormal(const Vector2D &normal)
Returns builder with plane normal.
jet::Vector2D
Vector2< double > Vector2D
Double-type 2D vector.
Definition: vector2.h:340
jet::Ray< T, 2 >
Class for 2-D ray.
Definition: ray2.h:21
jet::Plane2::Plane2
Plane2(const Plane2 &other)
Copy constructor.
jet::Plane2::Builder::withPoint
Builder & withPoint(const Vector2D &point)
Returns builder with point on the plane.
jet::Plane2
2-D plane geometry.
Definition: plane2.h:20
jet::Plane2::Builder::makeShared
Plane2Ptr makeShared() const
Builds shared pointer of Plane2 instance.
jet::Plane2::normal
Vector2D normal
Plane normal.
Definition: plane2.h:25
jet
Definition: advection_solver2.h:18
jet::Surface2::transform
Transform2 transform
Local-to-world transform.
Definition: surface2.h:30
jet::Plane2::point
Vector2D point
Point that lies on the plane.
Definition: plane2.h:28
jet::Vector< T, 2 >
2-D vector class.
Definition: vector2.h:24
jet::SurfaceBuilderBase2
Base class for 2-D surface builder.
Definition: surface2.h:115
jet::Plane2::isBounded
bool isBounded() const override
Returns true if bounding box can be defined.
jet::BoundingBox< T, 2 >
2-D axis-aligned bounding box class.
Definition: bounding_box2.h:41
jet::Surface2
Abstract base class for 2-D surface.
Definition: surface2.h:27
jet::Plane2::builder
static Builder builder()
Returns builder fox Plane2.
jet::Plane2::Builder
Front-end to create Plane2 objects step by step.
Definition: plane2.h:71
jet::Plane2Ptr
std::shared_ptr< Plane2 > Plane2Ptr
Shared pointer for the Plane2 type.
Definition: plane2.h:65