circle.h Source File - ClanLib SDK
Description: circle.h Source File

circle.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 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
30#pragma once
31
32#include "point.h"
33
34namespace clan
35{
38
42 template<typename Type>
43 class Circlex
44 {
45 public:
47 Vec2<Type> position;
48
50 Type radius;
51
52 Circlex(Type x, Type y, Type radius) : position(x, y), radius(radius) { }
53 Circlex(const Vec2<Type> &p, Type radius) : position(p), radius(radius) { }
54 Circlex() : position(), radius(static_cast<Type> (0)) { }
55 Circlex(const Circlex<Type> &copy) = default;
56
57 bool is_inside(const Vec2<Type> &point) { return radius >= position.distance(point); }
58
59 Circlex<Type> &operator = (const Circlex<Type>& copy) = default;
60 bool operator == (const Circlex<Type>& circle) const { return ((position == circle.position) && (radius == circle.radius)); }
61 bool operator != (const Circlex<Type>& circle) const { return ((position != circle.position) || (radius != circle.radius)); }
62 };
63
65 class Circle : public Circlex<int>
66 {
67 public:
68 Circle(int x, int y, int radius) : Circlex<int>(x, y, radius) { }
69 Circle(const Vec2<int> &p, int radius) : Circlex<int>(p, radius) { }
70 Circle() : Circlex<int>(){ }
71 Circle(const Circlex<int> &copy) : Circlex<int>(copy){ }
72 };
73
75 class Circlef : public Circlex<float>
76 {
77 public:
78 Circlef(float x, float y, float radius) : Circlex<float>(x, y, radius) { }
79 Circlef(const Vec2<float> &p, float radius) : Circlex<float>(p, radius) { }
80 Circlef() : Circlex<float>(){ }
81 Circlef(const Circlex<float> &copy) : Circlex<float>(copy){ }
82 };
83
85 class Circled : public Circlex<double>
86 {
87 public:
88 Circled(double x, double y, double radius) : Circlex<double>(x, y, radius) { }
89 Circled(const Vec2<double> &p, double radius) : Circlex<double>(p, radius) { }
90 Circled() : Circlex<double>(){ }
91 Circled(const Circlex<double> &copy) : Circlex<double>(copy){ }
92 };
93
95}
clan::Circle::Circle
Circle(int x, int y, int radius)
Definition circle.h:68
clan::Circle::Circle
Circle()
Definition circle.h:70
clan::Circle::Circle
Circle(const Vec2< int > &p, int radius)
Definition circle.h:69
clan::Circle::Circle
Circle(const Circlex< int > &copy)
Definition circle.h:71
clan::Circled::Circled
Circled(const Vec2< double > &p, double radius)
Definition circle.h:89
clan::Circled::Circled
Circled()
Definition circle.h:90
clan::Circled::Circled
Circled(double x, double y, double radius)
Definition circle.h:88
clan::Circled::Circled
Circled(const Circlex< double > &copy)
Definition circle.h:91
clan::Circlef::Circlef
Circlef(const Circlex< float > &copy)
Definition circle.h:81
clan::Circlef::Circlef
Circlef(const Vec2< float > &p, float radius)
Definition circle.h:79
clan::Circlef::Circlef
Circlef(float x, float y, float radius)
Definition circle.h:78
clan::Circlef::Circlef
Circlef()
Definition circle.h:80
clan::Circlex::operator=
Circlex< Type > & operator=(const Circlex< Type > &copy)=default
clan::Circlex::position
Vec2< Type > position
Circle center point.
Definition circle.h:47
clan::Circlex::operator!=
bool operator!=(const Circlex< Type > &circle) const
Definition circle.h:61
clan::Circlex::Circlex
Circlex(const Vec2< Type > &p, Type radius)
Definition circle.h:53
clan::Circlex::Circlex
Circlex(const Circlex< Type > &copy)=default
clan::Circlex::Circlex
Circlex()
Definition circle.h:54
clan::Circlex::radius
Type radius
Circle radius.
Definition circle.h:50
clan::Circlex::Circlex
Circlex(Type x, Type y, Type radius)
Definition circle.h:52
clan::Circlex::is_inside
bool is_inside(const Vec2< Type > &point)
Definition circle.h:57
clan::Circlex::operator==
bool operator==(const Circlex< Type > &circle) const
Definition circle.h:60
clan::Vec2
2D vector
Definition vec2.h:76
clan::FillMode::point
@ point
Definition graphic_context.h:78
clan
Definition clanapp.h:36
clan::Key::y
@ y
Definition keys.h:105
clan::Key::p
@ p
Definition keys.h:96
clan::Key::x
@ x
Definition keys.h:104