ClanLib
2.3.7
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
Sources
API
Core
Math
line.h
Go to the documentation of this file.
1
/*
2
** ClanLib SDK
3
** Copyright (c) 1997-2011 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
31
32
#pragma once
33
34
#include "../api_core.h"
35
36
template
<
typename
Type>
37
class
CL_Line2x
;
38
39
template
<
typename
Type>
40
class
CL_Line3x
;
41
42
template
<
typename
Type>
43
class
CL_Rectx
;
44
45
template
<
typename
Type>
46
class
CL_Vec2
;
47
48
class
CL_Angle
;
49
54
template
<
typename
Type>
55
class
CL_Line3x
56
{
57
public
:
58
CL_Vec3<Type>
p
;
59
CL_Vec3<Type>
q
;
60
61
CL_Line3x
() { }
62
CL_Line3x
(
const
CL_Line3x<Type>
©) {
p
= copy.
p
;
q
= copy.
q
;}
63
CL_Line3x
(
const
CL_Vec3<Type>
&point_p,
const
CL_Vec3<Type>
&point_q) {
p
= point_p;
q
= point_q; }
64
67
public
:
74
CL_Vec3<Type>
get_intersection
(
const
CL_Line3x<Type>
&second,
bool
&intersect, Type range = (Type) 0.5 )
const
;
75
79
public
:
81
CL_Line3x<Type>
&
operator =
(
const
CL_Line3x<Type>
& copy) {
p
= copy.
p
;
q
= copy.
q
;
return
*
this
; }
82
84
bool
operator ==
(
const
CL_Line3x<Type>
& line)
const
{
return
((
p
== line.
p
) && (
q
== line.
q
));}
85
87
bool
operator !=
(
const
CL_Line3x<Type>
& line)
const
{
return
((
p
!= line.
p
) || (
q
!= line.
q
));}
89
};
90
95
template
<
typename
Type>
96
class
CL_Line2x
97
{
98
public
:
100
CL_Vec2<Type>
p
;
101
102
// \brief Another point on the line
103
CL_Vec2<Type>
q
;
104
105
CL_Line2x
() { }
106
CL_Line2x
(
const
CL_Line2x<Type>
©) {
p
= copy.
p
;
q
= copy.
q
;}
107
CL_Line2x
(
const
CL_Vec2<Type>
&point_p,
const
CL_Vec2<Type>
&point_q) {
p
= point_p;
q
= point_q; }
108
CL_Line2x
(
const
CL_Vec2<Type>
&point_p, Type gradient) {
p
= point_p;
q
.x = (Type) 1;
q
.y = gradient; }
109
112
public
:
118
CL_Vec2<Type>
get_intersection
(
const
CL_Line2x<Type>
&second,
bool
&intersect )
const
;
119
124
Type
point_right_of_line
(
CL_Vec2<Type>
point )
const
{
return
(
q
.x -
p
.x) * (point.
y
-
p
.y) - (point.
x
-
p
.x) * (
q
.y -
p
.y);}
125
129
130
public
:
131
135
public
:
137
CL_Line2x<Type>
&
operator =
(
const
CL_Line2x<Type>
& copy) {
p
= copy.
p
;
q
= copy.
q
;
return
*
this
; }
138
140
bool
operator ==
(
const
CL_Line2x<Type>
& line)
const
{
return
((
p
== line.
p
) && (
q
== line.
q
));}
141
143
bool
operator !=
(
const
CL_Line2x<Type>
& line)
const
{
return
((
p
!= line.
p
) || (
q
!= line.
q
));}
145
};
146
150
class
CL_Line2
:
public
CL_Line2x
<int>
151
{
152
public
:
153
CL_Line2
() :
CL_Line2x
<int>() { }
154
CL_Line2
(
const
CL_Line2x<int>
©) :
CL_Line2x
<int>(copy) { }
155
CL_Line2
(
const
CL_Vec2<int>
&point_p,
const
CL_Vec2<int>
&point_q) :
CL_Line2x
<int>(point_p, point_q) { }
156
CL_Line2
(
const
CL_Vec2<int>
&point_p,
int
gradient) :
CL_Line2x
<int>(point_p, gradient) { }
157
};
158
162
class
CL_Line2f
:
public
CL_Line2x
<float>
163
{
164
public
:
165
CL_Line2f
() :
CL_Line2x
<float>() { }
166
CL_Line2f
(
const
CL_Line2x<float>
©) :
CL_Line2x
<float>(copy) { }
167
CL_Line2f
(
const
CL_Vec2<float>
&point_p,
const
CL_Vec2<float>
&point_q) :
CL_Line2x
<float>(point_p, point_q) { }
168
CL_Line2f
(
const
CL_Vec2<float>
&point_p,
float
gradient) :
CL_Line2x
<float>(point_p, gradient) { }
169
};
170
174
class
CL_Line2d
:
public
CL_Line2x
<double>
175
{
176
public
:
177
CL_Line2d
() :
CL_Line2x
<double>() { }
178
CL_Line2d
(
const
CL_Line2x<double>
©) :
CL_Line2x
<double>(copy) { }
179
CL_Line2d
(
const
CL_Vec2<double>
&point_p,
const
CL_Vec2<double>
&point_q) :
CL_Line2x
<double>(point_p, point_q) { }
180
CL_Line2d
(
const
CL_Vec2<double>
&point_p,
double
gradient) :
CL_Line2x
<double>(point_p, gradient) { }
181
};
182
186
class
CL_Line3
:
public
CL_Line3x
<int>
187
{
188
public
:
189
CL_Line3
() :
CL_Line3x
<int>() { }
190
CL_Line3
(
const
CL_Line3x<int>
©) :
CL_Line3x
<int>(copy) { }
191
CL_Line3
(
const
CL_Vec3<int>
&point_p,
const
CL_Vec3<int>
&point_q) :
CL_Line3x
<int>(point_p, point_q) { }
192
};
193
197
class
CL_Line3f
:
public
CL_Line3x
<float>
198
{
199
public
:
200
CL_Line3f
() :
CL_Line3x
<float>() { }
201
CL_Line3f
(
const
CL_Line3x<float>
©) :
CL_Line3x
<float>(copy) { }
202
CL_Line3f
(
const
CL_Vec3<float>
&point_p,
const
CL_Vec3<float>
&point_q) :
CL_Line3x
<float>(point_p, point_q) { }
203
};
204
208
class
CL_Line3d
:
public
CL_Line3x
<double>
209
{
210
public
:
211
CL_Line3d
() :
CL_Line3x
<double>() { }
212
CL_Line3d
(
const
CL_Line3x<double>
©) :
CL_Line3x
<double>(copy) { }
213
CL_Line3d
(
const
CL_Vec3<double>
&podouble_p,
const
CL_Vec3<double>
&podouble_q) :
CL_Line3x
<double>(podouble_p, podouble_q) { }
214
};
215
Generated on Fri Jun 14 2013 13:05:45 for ClanLib by
1.8.4