ClanLib
2.3.7
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
Sources
API
Core
Math
circle.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
** Harry Storbacka
27
** Mark Page
28
*/
29
32
33
#pragma once
34
35
#include "
point.h
"
36
41
template
<
typename
Type>
42
class
CL_Circlex
43
{
44
public
:
46
CL_Vec2<Type>
position
;
47
49
Type
radius
;
50
51
CL_Circlex
(Type x, Type y, Type
radius
) :
position
(x,y), radius(radius) { }
52
CL_Circlex
(
const
CL_Vec2<Type>
&p, Type
radius
) :
position
(p), radius(radius) { }
53
CL_Circlex
() :
radius
( (Type) 0 ) { }
54
CL_Circlex
(
const
CL_Circlex<Type>
©) {
position
= copy.
position
;
radius
= copy.
radius
;}
55
58
public
:
59
60
bool
is_inside
(
const
CL_Vec2<Type>
&point ) {
return
radius
>=
position
.distance(point);}
61
65
public
:
67
CL_Circlex<Type>
&
operator =
(
const
CL_Circlex<Type>
& copy) {
position
= copy.
position
;
radius
= copy.
radius
;
return
*
this
; }
68
70
bool
operator ==
(
const
CL_Circlex<Type>
& circle)
const
{
return
((
position
== circle.
position
) && (
radius
== circle.
radius
));}
71
73
bool
operator !=
(
const
CL_Circlex<Type>
& circle)
const
{
return
((
position
!= circle.
position
) || (
radius
!= circle.
radius
));}
75
};
76
80
class
CL_Circle
:
public
CL_Circlex
<int>
81
{
82
public
:
83
CL_Circle
(
int
x,
int
y,
int
radius
) :
CL_Circlex
<int>(x, y, radius) { }
84
CL_Circle
(
const
CL_Vec2<int>
&p,
int
radius
) :
CL_Circlex
<int>(p, radius) { }
85
CL_Circle
() :
CL_Circlex
<int>(){ }
86
CL_Circle
(
const
CL_Circlex<int>
©) :
CL_Circlex
<int>(copy){ }
87
};
88
92
class
CL_Circlef
:
public
CL_Circlex
<float>
93
{
94
public
:
95
CL_Circlef
(
float
x,
float
y,
float
radius
) :
CL_Circlex
<float>(x, y, radius) { }
96
CL_Circlef
(
const
CL_Vec2<float>
&p,
float
radius
) :
CL_Circlex
<float>(p, radius) { }
97
CL_Circlef
() :
CL_Circlex
<float>(){ }
98
CL_Circlef
(
const
CL_Circlex<float>
©) :
CL_Circlex
<float>(copy){ }
99
};
100
104
class
CL_Circled
:
public
CL_Circlex
<double>
105
{
106
public
:
107
CL_Circled
(
double
x,
double
y,
double
radius
) :
CL_Circlex
<double>(x, y, radius) { }
108
CL_Circled
(
const
CL_Vec2<double>
&p,
double
radius
) :
CL_Circlex
<double>(p, radius) { }
109
CL_Circled
() :
CL_Circlex
<double>(){ }
110
CL_Circled
(
const
CL_Circlex<double>
©) :
CL_Circlex
<double>(copy){ }
111
};
112
Generated on Fri Jun 14 2013 13:05:44 for ClanLib by
1.8.4