feisty meow concerns codebase 2.140
polygon.h
Go to the documentation of this file.
1#ifndef POLYGON_CLASS
2#define POLYGON_CLASS
3
4/*****************************************************************************\
5* *
6* Name : polygon *
7* Author : Chris Koeritz *
8* *
9*******************************************************************************
10* Copyright (c) 1992-$now By Author. This program is free software; you can *
11* redistribute it and/or modify it under the terms of the GNU General Public *
12* License as published by the Free Software Foundation; either version 2 of *
13* the License or (at your option) any later version. This is online at: *
14* http://www.fsf.org/copyleft/gpl.html *
15* Please send any updates to: fred@gruntose.com *
16\*****************************************************************************/
17
19
26#include "cartesian_objects.h"
27
28#include <basis/array.h>
29
30//hmmm: it might be nice to structuralize this.
31//hmmm: also deriving from an array of points is not so great.
32
33namespace geometric {
34
35class polygon : public basis::array<geometric::cartesian_point>
36{
37public:
40
41 void add(const cartesian_point &to_add);
43
44 int points() const { return length(); }
45 int sides() const { return points() - 1; }
46
49
51 bool inside(const cartesian_point &to_check);
53
55};
56
57} // namespace.
58
59#endif
60
Represents a sequential, ordered, contiguous collection of objects.
Definition array.h:54
int length() const
Returns the current reported length of the allocated C array.
Definition array.h:115
Provides a geometric point that use double floating points numbers.
int points() const
Definition polygon.h:44
void add(const cartesian_point &to_add)
adds a new point to the list that represents the polygon's sides.
cartesian_point & operator[](int index)
retrieves the index-th point in the list.
int sides() const
Definition polygon.h:45
bool inside(const cartesian_point &to_check)
Returns true if the point "to_check" is inside of this polygon.
Definition polygon.cpp:26
Contains all of our objects for geometry and avoids name clashes.
Definition angle.h:25