TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Line.h
Go to the documentation of this file.
1 
12 #ifndef G3D_LINE_H
13 #define G3D_LINE_H
14 
15 #include "G3D/platform.h"
16 #include "G3D/Vector3.h"
17 
18 namespace G3D {
19 
20 class Plane;
21 
25 class Line {
26 protected:
27 
30 
31  Line(const Vector3& point, const Vector3& direction) {
32  _point = point;
33  _direction = direction.direction();
34  }
35 
36 public:
37 
39  inline Line() {}
40 
41  Line(class BinaryInput& b);
42 
43  void serialize(class BinaryOutput& b) const;
44 
45  void deserialize(class BinaryInput& b);
46 
47  virtual ~Line() {}
48 
52  static Line fromTwoPoints(const Vector3 &point1, const Vector3 &point2) {
53  return Line(point1, point2 - point1);
54  }
55 
60  return Line(point, direction);
61  }
62 
66  Vector3 closestPoint(const Vector3& pt) const;
67 
71  double distance(const Vector3& point) const {
72  return (closestPoint(point) - point).magnitude();
73  }
74 
76  Vector3 point() const;
77 
79  Vector3 direction() const;
80 
85  Vector3 intersection(const Plane &plane) const;
86 
87 
94  Vector3 closestPoint(const Line& B, float& minDist) const;
95 
96  inline Vector3 closestPoint(const Line& B) const {
97  float m;
98  return closestPoint(B, m);
99  }
100 };
101 
102 };// namespace
103 
104 
105 #endif
static Line fromPointAndDirection(const Vector3 &point, const Vector3 &direction)
Definition: Line.h:59
void serialize(class BinaryOutput &b) const
Definition: Line.cpp:40
Definition: Plane.h:25
Definition: BinaryInput.h:69
Definition: Line.h:25
Line()
Definition: Line.h:39
Definition: AABox.h:25
Vector3 direction() const
Definition: Line.cpp:63
Vector3 direction() const
Definition: Vector3.h:756
Definition: Vector3.h:58
Vector3 closestPoint(const Line &B) const
Definition: Line.h:96
virtual ~Line()
Definition: Line.h:47
Vector3 _direction
Definition: Line.h:29
Vector3 _point
Definition: Line.h:28
Vector3 closestPoint(const Vector3 &pt) const
Definition: Line.cpp:52
Line(const Vector3 &point, const Vector3 &direction)
Definition: Line.h:31
Definition: BinaryOutput.h:52
double distance(const Vector3 &point) const
Definition: Line.h:71
Vector3 intersection(const Plane &plane) const
Definition: Line.cpp:17
static Line fromTwoPoints(const Vector3 &point1, const Vector3 &point2)
Definition: Line.h:52
Vector3 point() const
Definition: Line.cpp:58
void deserialize(class BinaryInput &b)
Definition: Line.cpp:46