Transform2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: Transform2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Represents 2-D rigid body transform.
6 > Created Time: 2017/03/29
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_TRANSFORM2_H
10 #define CUBBYFLOW_TRANSFORM2_H
11 
13 #include <Core/Ray/Ray2.h>
14 #include <Core/Vector/Vector2.h>
15 
16 namespace CubbyFlow
17 {
21  class Transform2
22  {
23  public:
25  Transform2();
26 
28  Transform2(const Vector2D& translation, double orientation);
29 
31  const Vector2D& GetTranslation() const;
32 
34  void SetTranslation(const Vector2D& translation);
35 
37  double GetOrientation() const;
38 
40  void SetOrientation(double orientation);
41 
43  Vector2D ToLocal(const Vector2D& pointInWorld) const;
44 
46  Vector2D ToLocalDirection(const Vector2D& dirInWorld) const;
47 
49  Ray2D ToLocal(const Ray2D& rayInWorld) const;
50 
52  BoundingBox2D ToLocal(const BoundingBox2D& bboxInWorld) const;
53 
55  Vector2D ToWorld(const Vector2D& pointInLocal) const;
56 
58  Vector2D ToWorldDirection(const Vector2D& dirInLocal) const;
59 
61  Ray2D ToWorld(const Ray2D& rayInLocal) const;
62 
64  BoundingBox2D ToWorld(const BoundingBox2D& bboxInLocal) const;
65 
66  private:
67  Vector2D m_translation;
68  double m_orientation = 0.0;
69  double m_cosAngle = 1.0;
70  double m_sinAngle = 0.0;
71  };
72 }
73 
74 #endif
Vector2D ToLocal(const Vector2D &pointInWorld) const
Transforms a point in world coordinate to the local frame.
double GetOrientation() const
Returns the orientation in radians.
void SetOrientation(double orientation)
Sets the orientation in radians.
Vector2D ToWorld(const Vector2D &pointInLocal) const
Transforms a point in local space to the world coordinate.
Class for 2-D ray.
Definition: Ray2.h:23
Represents 2-D rigid body transform.
Definition: Transform2.h:21
void SetTranslation(const Vector2D &translation)
Sets the translation.
2-D axis-aligned bounding box class.
Definition: BoundingBox2.h:44
Vector2D ToLocalDirection(const Vector2D &dirInWorld) const
Transforms a direction in world coordinate to the local frame.
Definition: pybind11Utils.h:24
const Vector2D & GetTranslation() const
Returns the translation.
Vector2D ToWorldDirection(const Vector2D &dirInLocal) const
Transforms a direction in local space to the world coordinate.
2-D vector class.
Definition: Vector2.h:26
Transform2()
Constructs identity transform.