line_ray.h
1 /*
2 ** UICore
3 ** Copyright (c) 1997-2015 The UICore Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries UICore may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Mark Page
27 */
28 
29 #pragma once
30 
31 namespace uicore
32 {
33  template<typename Type>
34  class LineRay2x;
35 
36  template<typename Type>
37  class LineRay3x;
38 
39  template<typename Type>
40  class Vec2;
41 
42  template<typename Type>
43  class Vec3;
44 
49  template<typename Type>
50  class LineRay3x
51  {
52  public:
55 
56  // \brief Direction of the ray
58 
59  LineRay3x() : p(), v() {}
60  LineRay3x(const LineRay3x<Type> &copy) : p(copy.p), v(copy.v) {}
61  LineRay3x(const Vec3<Type> &point_p, const Vec3<Type> &direction_v) : p(point_p), v(direction_v) {}
62 
64  LineRay3x<Type> &operator = (const LineRay3x<Type>& copy) { p = copy.p; v = copy.v; return *this; }
65 
67  bool operator == (const LineRay3x<Type>& line) const { return ((p == line.p) && (v == line.v)); }
68 
70  bool operator != (const LineRay3x<Type>& line) const { return ((p != line.p) || (v != line.v)); }
71  };
72 
77  template<typename Type>
78  class LineRay2x
79  {
80  public:
83 
84  // \brief Direction of the ray
86 
87  LineRay2x() : p(), v() {}
88  LineRay2x(const LineRay2x<Type> &copy) : p(copy.p), v(copy.v) {}
89  LineRay2x(const Vec2<Type> &point_p, const Vec2<Type> &direction_v) : p(point_p), v(direction_v) {}
90 
92  LineRay2x<Type> &operator = (const LineRay2x<Type>& copy) { p = copy.p; v = copy.v; return *this; }
93 
95  bool operator == (const LineRay2x<Type>& line) const { return ((p == line.p) && (v == line.v)); }
96 
98  bool operator != (const LineRay2x<Type>& line) const { return ((p != line.p) || (v != line.v)); }
99  };
100 
104  class LineRay2 : public LineRay2x<int>
105  {
106  public:
107  LineRay2() : LineRay2x<int>() {}
108  LineRay2(const LineRay2x<int> &copy) : LineRay2x<int>(copy) {}
109  LineRay2(const Vec2<int> &point_p, const Vec2<int> &direction_v) : LineRay2x<int>(point_p, direction_v) {}
110  };
111 
115  class LineRay2f : public LineRay2x<float>
116  {
117  public:
118  LineRay2f() : LineRay2x<float>() {}
119  LineRay2f(const LineRay2x<float> &copy) : LineRay2x<float>(copy) {}
120  LineRay2f(const Vec2<float> &point_p, const Vec2<float> &direction_v) : LineRay2x<float>(point_p, direction_v) {}
121  };
122 
126  class LineRay2d : public LineRay2x<double>
127  {
128  public:
129  LineRay2d() : LineRay2x<double>() {}
130  LineRay2d(const LineRay2x<double> &copy) : LineRay2x<double>(copy) {}
131  LineRay2d(const Vec2<double> &point_p, const Vec2<double> &direction_v) : LineRay2x<double>(point_p, direction_v) {}
132  };
133 
137  class LineRay3 : public LineRay3x<int>
138  {
139  public:
140  LineRay3() : LineRay3x<int>() {}
141  LineRay3(const LineRay3x<int> &copy) : LineRay3x<int>(copy) {}
142  LineRay3(const Vec3<int> &point_p, const Vec3<int> &direction_v) : LineRay3x<int>(point_p, direction_v) {}
143  };
144 
148  class LineRay3f : public LineRay3x<float>
149  {
150  public:
151  LineRay3f() : LineRay3x<float>() {}
152  LineRay3f(const LineRay3x<float> &copy) : LineRay3x<float>(copy) {}
153  LineRay3f(const Vec3<float> &point_p, const Vec3<float> &direction_v) : LineRay3x<float>(point_p, direction_v) {}
154  };
155 
159  class LineRay3d : public LineRay3x<double>
160  {
161  public:
162  LineRay3d() : LineRay3x<double>() {}
163  LineRay3d(const LineRay3x<double> &copy) : LineRay3x<double>(copy) {}
164  LineRay3d(const Vec3<double> &point_p, const Vec3<double> &direction_v) : LineRay3x<double>(point_p, direction_v) {}
165  };
166 }
LineRay3x(const LineRay3x< Type > &copy)
Definition: line_ray.h:60
Vec2< Type > p
Start point on the line ray.
Definition: line_ray.h:82
LineRay3f()
Definition: line_ray.h:151
Vec2< Type > v
Definition: line_ray.h:85
2D line ray - Integer
Definition: line_ray.h:104
LineRay2(const Vec2< int > &point_p, const Vec2< int > &direction_v)
Definition: line_ray.h:109
LineRay3d(const Vec3< double > &point_p, const Vec3< double > &direction_v)
Definition: line_ray.h:164
bool operator!=(const LineRay2x< Type > &line) const
!= operator.
Definition: line_ray.h:98
bool operator==(const LineRay2x< Type > &line) const
== operator.
Definition: line_ray.h:95
LineRay2x(const LineRay2x< Type > &copy)
Definition: line_ray.h:88
bool operator!=(const LineRay3x< Type > &line) const
!= operator.
Definition: line_ray.h:70
LineRay2f(const Vec2< float > &point_p, const Vec2< float > &direction_v)
Definition: line_ray.h:120
2D vector
Definition: line.h:43
3D vector
Definition: line_ray.h:43
LineRay2f()
Definition: line_ray.h:118
LineRay2x(const Vec2< Type > &point_p, const Vec2< Type > &direction_v)
Definition: line_ray.h:89
LineRay3d()
Definition: line_ray.h:162
LineRay2d(const Vec2< double > &point_p, const Vec2< double > &direction_v)
Definition: line_ray.h:131
3D line ray - Float
Definition: line_ray.h:148
LineRay3f(const LineRay3x< float > &copy)
Definition: line_ray.h:152
3D line ray - Integer
Definition: line_ray.h:137
2D line ray - Double
Definition: line_ray.h:126
LineRay2d()
Definition: line_ray.h:129
LineRay3d(const LineRay3x< double > &copy)
Definition: line_ray.h:163
3D line ray
Definition: line_ray.h:37
LineRay3(const LineRay3x< int > &copy)
Definition: line_ray.h:141
Vec3< Type > p
Start point on the line ray.
Definition: line_ray.h:54
LineRay2f(const LineRay2x< float > &copy)
Definition: line_ray.h:119
LineRay2d(const LineRay2x< double > &copy)
Definition: line_ray.h:130
bool operator==(const LineRay3x< Type > &line) const
== operator.
Definition: line_ray.h:67
LineRay3(const Vec3< int > &point_p, const Vec3< int > &direction_v)
Definition: line_ray.h:142
LineRay3f(const Vec3< float > &point_p, const Vec3< float > &direction_v)
Definition: line_ray.h:153
LineRay3x(const Vec3< Type > &point_p, const Vec3< Type > &direction_v)
Definition: line_ray.h:61
Vec3< Type > v
Definition: line_ray.h:57
LineRay2(const LineRay2x< int > &copy)
Definition: line_ray.h:108
2D line ray - Float
Definition: line_ray.h:115
3D line ray - Double
Definition: line_ray.h:159
LineRay3x()
Definition: line_ray.h:59
LineRay2()
Definition: line_ray.h:107
LineRay2x< Type > & operator=(const LineRay2x< Type > &copy)
= operator.
Definition: line_ray.h:92
2D line ray
Definition: line_ray.h:34
LineRay3x< Type > & operator=(const LineRay3x< Type > &copy)
= operator.
Definition: line_ray.h:64
LineRay2x()
Definition: line_ray.h:87
Definition: Application/application.h:35
LineRay3()
Definition: line_ray.h:140