Jet  v1.3.3
box2.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_BOX2_H_
8 #define INCLUDE_JET_BOX2_H_
9 
10 #include <jet/surface2.h>
11 #include <jet/bounding_box2.h>
12 
13 namespace jet {
14 
22 class Box2 final : public Surface2 {
23  public:
24  class Builder;
25 
28 
31  const Transform2& transform = Transform2(),
32  bool isNormalFlipped = false);
33 
36  const Vector2D& lowerCorner,
37  const Vector2D& upperCorner,
38  const Transform2& transform = Transform2(),
39  bool isNormalFlipped = false);
40 
44  const Transform2& transform = Transform2(),
45  bool isNormalFlipped = false);
46 
48  Box2(const Box2& other);
49 
51  static Builder builder();
52 
53  protected:
54  // Surface2 implementations
55 
56  Vector2D closestPointLocal(const Vector2D& otherPoint) const override;
57 
58  bool intersectsLocal(const Ray2D& ray) const override;
59 
60  BoundingBox2D boundingBoxLocal() const override;
61 
62  Vector2D closestNormalLocal(const Vector2D& otherPoint) const override;
63 
65  const Ray2D& ray) const override;
66 };
67 
69 typedef std::shared_ptr<Box2> Box2Ptr;
70 
71 
75 class Box2::Builder final : public SurfaceBuilderBase2<Box2::Builder> {
76  public:
79 
82 
85 
87  Box2 build() const;
88 
91 
92  private:
93  Vector2D _lowerCorner{0, 0};
94  Vector2D _upperCorner{1, 1};
95 };
96 
97 } // namespace jet
98 
99 
100 #endif // INCLUDE_JET_BOX2_H_
surface2.h
jet::Box2::Builder::makeShared
Box2Ptr makeShared() const
Builds shared pointer of Box2 instance.
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::Box2::bound
BoundingBox2D bound
Bounding box of this box.
Definition: box2.h:27
jet::Transform2
Represents 2-D rigid body transform.
Definition: transform2.h:19
jet::Vector2D
Vector2< double > Vector2D
Double-type 2D vector.
Definition: vector2.h:340
jet::Box2::closestNormalLocal
Vector2D closestNormalLocal(const Vector2D &otherPoint) const override
jet::Box2::boundingBoxLocal
BoundingBox2D boundingBoxLocal() const override
Returns the bounding box of this surface object in local frame.
jet::Ray< T, 2 >
Class for 2-D ray.
Definition: ray2.h:21
jet::Surface2::boundingBox
BoundingBox2D boundingBox() const
Returns the bounding box of this surface object.
jet::Box2::Box2
Box2(const Box2 &other)
Copy constructor.
jet::Box2::Box2
Box2(const Transform2 &transform=Transform2(), bool isNormalFlipped=false)
Constructs (0, 0) x (1, 1) box.
jet::BoundingBox2D
BoundingBox2< double > BoundingBox2D
Double-type 2-D BoundingBox.
Definition: bounding_box2.h:124
jet::Box2::closestPointLocal
Vector2D closestPointLocal(const Vector2D &otherPoint) const override
jet::Box2::builder
static Builder builder()
Returns builder fox Box2.
jet
Definition: advection_solver2.h:18
jet::Surface2::transform
Transform2 transform
Local-to-world transform.
Definition: surface2.h:30
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::Box2Ptr
std::shared_ptr< Box2 > Box2Ptr
Shared pointer type for the Box2.
Definition: box2.h:69
jet::Box2::intersectsLocal
bool intersectsLocal(const Ray2D &ray) const override
jet::Box2::closestIntersectionLocal
SurfaceRayIntersection2 closestIntersectionLocal(const Ray2D &ray) const override
Returns the closest intersection point for given ray in local frame.
jet::Box2
2-D box geometry.
Definition: box2.h:22
jet::Box2::Builder::withLowerCorner
Builder & withLowerCorner(const Vector2D &pt)
Returns builder with lower corner set.
bounding_box2.h
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::Box2::Builder::withBoundingBox
Builder & withBoundingBox(const BoundingBox2D &bbox)
Returns builder with bounding box.
jet::Box2::Builder::withUpperCorner
Builder & withUpperCorner(const Vector2D &pt)
Returns builder with upper corner set.
jet::Box2::Builder
Front-end to create Box2 objects step by step.
Definition: box2.h:75
jet::Box2::Builder::build
Box2 build() const
Builds Box2.
jet::Box2::Box2
Box2(const BoundingBox2D &boundingBox, const Transform2 &transform=Transform2(), bool isNormalFlipped=false)
Constructs a box with BoundingBox2D instance.
jet::Box2::Box2
Box2(const Vector2D &lowerCorner, const Vector2D &upperCorner, const Transform2 &transform=Transform2(), bool isNormalFlipped=false)
Constructs a box with given lowerCorner and upperCorner.