line_ray.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 The ClanLib 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 ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Mark Page
27 */
28 
29 
30 #pragma once
31 
32 
33 namespace clan
34 {
37 
38 template<typename Type>
39 class LineRay2x;
40 
41 template<typename Type>
42 class LineRay3x;
43 
44 template<typename Type>
45 class Vec2;
46 
47 template<typename Type>
48 class Vec3;
49 
50 class Angle;
51 
56 template<typename Type>
57 class LineRay3x
58 {
59 public:
62 
63  // \brief Direction of the ray
65 
66  LineRay3x(): p(), v() {}
67  LineRay3x(const LineRay3x<Type> &copy): p(copy.p), v(copy.v) {}
68  LineRay3x(const Vec3<Type> &point_p, const Vec3<Type> &direction_v): p(point_p), v(direction_v) {}
69 
72 
73 public:
74 
78 
79 public:
80 
82  LineRay3x<Type> &operator = (const LineRay3x<Type>& copy) { p = copy.p; v = copy.v; return *this; }
83 
85  bool operator == (const LineRay3x<Type>& line) const {return ((p == line.p) && (v == line.v));}
86 
88  bool operator != (const LineRay3x<Type>& line) const {return ((p != line.p) || (v != line.v));}
90 };
91 
96 template<typename Type>
97 class LineRay2x
98 {
99 public:
102 
103  // \brief Direction of the ray
105 
106  LineRay2x(): p(), v() {}
107  LineRay2x(const LineRay2x<Type> &copy): p(copy.p), v(copy.v) {}
108  LineRay2x(const Vec2<Type> &point_p, const Vec2<Type> &direction_v): p(point_p), v(direction_v) {}
109 
112 
113 public:
114 
118 
119 public:
120 
122  LineRay2x<Type> &operator = (const LineRay2x<Type>& copy) { p = copy.p; v = copy.v; return *this; }
123 
125  bool operator == (const LineRay2x<Type>& line) const {return ((p == line.p) && (v == line.v));}
126 
128  bool operator != (const LineRay2x<Type>& line) const {return ((p != line.p) || (v != line.v));}
130 };
131 
135 class LineRay2 : public LineRay2x<int>
136 {
137 public:
138  LineRay2() : LineRay2x<int>() {}
139  LineRay2(const LineRay2x<int> &copy) : LineRay2x<int>(copy) {}
140  LineRay2(const Vec2<int> &point_p, const Vec2<int> &direction_v) : LineRay2x<int>(point_p, direction_v) {}
141 
142 };
143 
147 class LineRay2f : public LineRay2x<float>
148 {
149 public:
150  LineRay2f() : LineRay2x<float>() {}
151  LineRay2f(const LineRay2x<float> &copy) : LineRay2x<float>(copy) {}
152  LineRay2f(const Vec2<float> &point_p, const Vec2<float> &direction_v) : LineRay2x<float>(point_p, direction_v) {}
153 
154 };
155 
159 class LineRay2d : public LineRay2x<double>
160 {
161 public:
162  LineRay2d() : LineRay2x<double>() {}
163  LineRay2d(const LineRay2x<double> &copy) : LineRay2x<double>(copy) {}
164  LineRay2d(const Vec2<double> &point_p, const Vec2<double> &direction_v) : LineRay2x<double>(point_p, direction_v) {}
165 
166 };
167 
171 class LineRay3 : public LineRay3x<int>
172 {
173 public:
174  LineRay3() : LineRay3x<int>() {}
175  LineRay3(const LineRay3x<int> &copy) : LineRay3x<int>(copy) {}
176  LineRay3(const Vec3<int> &point_p, const Vec3<int> &direction_v) : LineRay3x<int>(point_p, direction_v) {}
177 
178 };
179 
183 class LineRay3f : public LineRay3x<float>
184 {
185 public:
186  LineRay3f() : LineRay3x<float>() {}
187  LineRay3f(const LineRay3x<float> &copy) : LineRay3x<float>(copy) {}
188  LineRay3f(const Vec3<float> &point_p, const Vec3<float> &direction_v) : LineRay3x<float>(point_p, direction_v) {}
189 
190 };
191 
195 class LineRay3d : public LineRay3x<double>
196 {
197 public:
198  LineRay3d() : LineRay3x<double>() {}
199  LineRay3d(const LineRay3x<double> &copy) : LineRay3x<double>(copy) {}
200  LineRay3d(const Vec3<double> &point_p, const Vec3<double> &direction_v) : LineRay3x<double>(point_p, direction_v) {}
201 
202 };
203 
204 }
205 
3D line ray - Double
Definition: line_ray.h:196
2D line ray - Integer
Definition: line_ray.h:136
Vec3< Type > v
Definition: line_ray.h:64
LineRay3f()
Definition: line_ray.h:186
2D line ray - Float
Definition: line_ray.h:148
LineRay3f(const Vec3< float > &point_p, const Vec3< float > &direction_v)
Definition: line_ray.h:188
LineRay3f(const LineRay3x< float > &copy)
Definition: line_ray.h:187
3D line ray - Integer
Definition: line_ray.h:172
LineRay2(const Vec2< int > &point_p, const Vec2< int > &direction_v)
Definition: line_ray.h:140
LineRay2(const LineRay2x< int > &copy)
Definition: line_ray.h:139
Vec2< Type > v
Definition: line_ray.h:104
bool operator!=(const LineRay2x< Type > &line) const
!= operator.
Definition: line_ray.h:128
LineRay3(const LineRay3x< int > &copy)
Definition: line_ray.h:175
LineRay3()
Definition: line_ray.h:174
bool operator!=(const LineRay3x< Type > &line) const
!= operator.
Definition: line_ray.h:88
LineRay3d(const LineRay3x< double > &copy)
Definition: line_ray.h:199
LineRay2d()
Definition: line_ray.h:162
LineRay3d()
Definition: line_ray.h:198
LineRay2x(const Vec2< Type > &point_p, const Vec2< Type > &direction_v)
Definition: line_ray.h:108
LineRay2x< Type > & operator=(const LineRay2x< Type > &copy)
= operator.
Definition: line_ray.h:122
LineRay2()
Definition: line_ray.h:138
3D line ray
Definition: line_ray.h:42
Angle class.
Definition: angle.h:63
2D line ray - Double
Definition: line_ray.h:160
LineRay2f(const Vec2< float > &point_p, const Vec2< float > &direction_v)
Definition: line_ray.h:152
2D vector
Definition: line.h:48
LineRay2f()
Definition: line_ray.h:150
bool operator==(const LineRay3x< Type > &line) const
== operator.
Definition: line_ray.h:85
3D line ray - Float
Definition: line_ray.h:184
bool operator==(const LineRay2x< Type > &line) const
== operator.
Definition: line_ray.h:125
Definition: clanapp.h:36
LineRay3(const Vec3< int > &point_p, const Vec3< int > &direction_v)
Definition: line_ray.h:176
LineRay2d(const LineRay2x< double > &copy)
Definition: line_ray.h:163
LineRay3d(const Vec3< double > &point_p, const Vec3< double > &direction_v)
Definition: line_ray.h:200
Vec3< Type > p
Start point on the line ray.
Definition: line_ray.h:61
LineRay3x< Type > & operator=(const LineRay3x< Type > &copy)
= operator.
Definition: line_ray.h:82
LineRay2f(const LineRay2x< float > &copy)
Definition: line_ray.h:151
LineRay3x(const LineRay3x< Type > &copy)
Definition: line_ray.h:67
Vec2< Type > p
Start point on the line ray.
Definition: line_ray.h:101
LineRay2x()
Definition: line_ray.h:106
LineRay2x(const LineRay2x< Type > &copy)
Definition: line_ray.h:107
3D vector
Definition: line_ray.h:48
LineRay2d(const Vec2< double > &point_p, const Vec2< double > &direction_v)
Definition: line_ray.h:164
2D line ray
Definition: line_ray.h:39
LineRay3x(const Vec3< Type > &point_p, const Vec3< Type > &direction_v)
Definition: line_ray.h:68
LineRay3x()
Definition: line_ray.h:66