line_ray.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 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 #include "../api_core.h"
33 
34 namespace clan
35 {
38 
39 template<typename Type>
40 class LineRay2x;
41 
42 template<typename Type>
43 class LineRay3x;
44 
45 template<typename Type>
46 class Vec2;
47 
48 template<typename Type>
49 class Vec3;
50 
51 class Angle;
52 
57 template<typename Type>
58 class LineRay3x
59 {
60 public:
63 
64  // \brief Direction of the ray
66 
67  LineRay3x() { }
68  LineRay3x(const LineRay3x<Type> &copy) { p = copy.p; v = copy.v;}
69  LineRay3x(const Vec3<Type> &point_p, const Vec3<Type> &direction_v) { p = point_p; v = direction_v; }
70 
73 
74 public:
75 
79 
80 public:
81 
83  LineRay3x<Type> &operator = (const LineRay3x<Type>& copy) { p = copy.p; v = copy.v; return *this; }
84 
86  bool operator == (const LineRay3x<Type>& line) const {return ((p == line.p) && (v == line.v));}
87 
89  bool operator != (const LineRay3x<Type>& line) const {return ((p != line.p) || (v != line.v));}
91 };
92 
97 template<typename Type>
98 class LineRay2x
99 {
100 public:
103 
104  // \brief Direction of the ray
106 
107  LineRay2x() { }
108  LineRay2x(const LineRay2x<Type> &copy) { p = copy.p; v = copy.v;}
109  LineRay2x(const Vec2<Type> &point_p, const Vec2<Type> &direction_v) { p = point_p; v = direction_v; }
110 
113 
114 public:
115 
119 
120 public:
121 
123  LineRay2x<Type> &operator = (const LineRay2x<Type>& copy) { p = copy.p; v = copy.v; return *this; }
124 
126  bool operator == (const LineRay2x<Type>& line) const {return ((p == line.p) && (v == line.v));}
127 
129  bool operator != (const LineRay2x<Type>& line) const {return ((p != line.p) || (v != line.v));}
131 };
132 
136 class LineRay2 : public LineRay2x<int>
137 {
138 public:
139  LineRay2() : LineRay2x<int>() {}
140  LineRay2(const LineRay2x<int> &copy) : LineRay2x<int>(copy) {}
141  LineRay2(const Vec2<int> &point_p, const Vec2<int> &direction_v) : LineRay2x<int>(point_p, direction_v) {}
142 
143 };
144 
148 class LineRay2f : public LineRay2x<float>
149 {
150 public:
151  LineRay2f() : LineRay2x<float>() {}
152  LineRay2f(const LineRay2x<float> &copy) : LineRay2x<float>(copy) {}
153  LineRay2f(const Vec2<float> &point_p, const Vec2<float> &direction_v) : LineRay2x<float>(point_p, direction_v) {}
154 
155 };
156 
160 class LineRay2d : public LineRay2x<double>
161 {
162 public:
163  LineRay2d() : LineRay2x<double>() {}
164  LineRay2d(const LineRay2x<double> &copy) : LineRay2x<double>(copy) {}
165  LineRay2d(const Vec2<double> &point_p, const Vec2<double> &direction_v) : LineRay2x<double>(point_p, direction_v) {}
166 
167 };
168 
172 class LineRay3 : public LineRay3x<int>
173 {
174 public:
175  LineRay3() : LineRay3x<int>() {}
176  LineRay3(const LineRay3x<int> &copy) : LineRay3x<int>(copy) {}
177  LineRay3(const Vec3<int> &point_p, const Vec3<int> &direction_v) : LineRay3x<int>(point_p, direction_v) {}
178 
179 };
180 
184 class LineRay3f : public LineRay3x<float>
185 {
186 public:
187  LineRay3f() : LineRay3x<float>() {}
188  LineRay3f(const LineRay3x<float> &copy) : LineRay3x<float>(copy) {}
189  LineRay3f(const Vec3<float> &point_p, const Vec3<float> &direction_v) : LineRay3x<float>(point_p, direction_v) {}
190 
191 };
192 
196 class LineRay3d : public LineRay3x<double>
197 {
198 public:
199  LineRay3d() : LineRay3x<double>() {}
200  LineRay3d(const LineRay3x<double> &copy) : LineRay3x<double>(copy) {}
201  LineRay3d(const Vec3<double> &point_p, const Vec3<double> &direction_v) : LineRay3x<double>(point_p, direction_v) {}
202 
203 };
204 
205 }
206 
bool operator!=(const LineRay2x< Type > &line) const
!= operator.
Definition: line_ray.h:129
LineRay2x(const Vec2< Type > &point_p, const Vec2< Type > &direction_v)
Definition: line_ray.h:109
Angle class.
Definition: angle.h:63
LineRay3f(const LineRay3x< float > &copy)
Definition: line_ray.h:188
LineRay2d()
Definition: line_ray.h:163
LineRay2(const Vec2< int > &point_p, const Vec2< int > &direction_v)
Definition: line_ray.h:141
2D line ray
Definition: line_ray.h:40
Vec2< Type > v
Definition: line_ray.h:105
LineRay3f()
Definition: line_ray.h:187
LineRay3d()
Definition: line_ray.h:199
3D line ray - Double
Definition: line_ray.h:196
2D line ray - Float
Definition: line_ray.h:148
LineRay3(const Vec3< int > &point_p, const Vec3< int > &direction_v)
Definition: line_ray.h:177
LineRay3d(const LineRay3x< double > &copy)
Definition: line_ray.h:200
bool operator==(const LineRay2x< Type > &line) const
== operator.
Definition: line_ray.h:126
LineRay2()
Definition: line_ray.h:139
LineRay3x< Type > & operator=(const LineRay3x< Type > &copy)
= operator.
Definition: line_ray.h:83
LineRay3x(const LineRay3x< Type > &copy)
Definition: line_ray.h:68
LineRay2x()
Definition: line_ray.h:107
Vec2< Type > p
Start point on the line ray.
Definition: line_ray.h:102
bool operator==(const LineRay3x< Type > &line) const
== operator.
Definition: line_ray.h:86
LineRay2d(const Vec2< double > &point_p, const Vec2< double > &direction_v)
Definition: line_ray.h:165
LineRay3()
Definition: line_ray.h:175
bool operator!=(const LineRay3x< Type > &line) const
!= operator.
Definition: line_ray.h:89
2D vector
Definition: line.h:49
LineRay2x< Type > & operator=(const LineRay2x< Type > &copy)
= operator.
Definition: line_ray.h:123
3D vector
Definition: line_ray.h:49
LineRay3f(const Vec3< float > &point_p, const Vec3< float > &direction_v)
Definition: line_ray.h:189
3D line ray
Definition: line_ray.h:43
LineRay2f(const Vec2< float > &point_p, const Vec2< float > &direction_v)
Definition: line_ray.h:153
LineRay2f(const LineRay2x< float > &copy)
Definition: line_ray.h:152
Vec3< Type > v
Definition: line_ray.h:65
LineRay2d(const LineRay2x< double > &copy)
Definition: line_ray.h:164
2D line ray - Integer
Definition: line_ray.h:136
2D line ray - Double
Definition: line_ray.h:160
LineRay3x()
Definition: line_ray.h:67
LineRay2f()
Definition: line_ray.h:151
LineRay3x(const Vec3< Type > &point_p, const Vec3< Type > &direction_v)
Definition: line_ray.h:69
3D line ray - Integer
Definition: line_ray.h:172
Vec3< Type > p
Start point on the line ray.
Definition: line_ray.h:62
LineRay3(const LineRay3x< int > &copy)
Definition: line_ray.h:176
LineRay2x(const LineRay2x< Type > &copy)
Definition: line_ray.h:108
LineRay3d(const Vec3< double > &point_p, const Vec3< double > &direction_v)
Definition: line_ray.h:201
3D line ray - Float
Definition: line_ray.h:184
LineRay2(const LineRay2x< int > &copy)
Definition: line_ray.h:140