first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / graphiq / library / geometric / ellipse.h
1 #ifndef ELLIPSE_CLASS
2 #define ELLIPSE_CLASS
3
4 /*****************************************************************************\
5 *                                                                             *
6 *  Name   : ellipse                                                           *
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
18 namespace geometric {
19
20 // forward.
21 class cartesian_point;
22 class double_angle;
23
24 //! Represents a geometric ellipse.
25 /*! An ellipse is specified by its height, width and center. */
26
27 class ellipse
28 {
29 public:
30   ellipse();
31   ellipse(const cartesian_point &center, double width_from_center,
32           double height_from_center);
33   ellipse(const ellipse &to_copy);
34
35   ~ellipse();
36
37   ellipse &operator = (const ellipse &to_copy);
38
39   double area() const;
40     //!< Returns the area occupied by the ellipse.
41
42   double perimeter() const;
43     //!< Returns the perimeter for the ellipse.
44     /*!< This is the length of the virtual string around the ellipse.  The
45     returned value is an approximation. */
46
47   bool inside(const cartesian_point &where) const;
48     //!< Returns true if the point is inside the ellipse.
49
50   cartesian_point location(const double_angle &where) const;
51     //!< Describes the locus of the ellipse (basically, where it lives).
52     /*!< Returns the point on the ellipse that lies on a ray from the center
53     of the ellipse directed at an angle "where". */
54
55   cartesian_point center() const;
56   double width_from_center() const;
57   double height_from_center() const;
58
59   void center(const cartesian_point &to_set);
60   void width_from_center(double to_set);
61   void height_from_center(double to_set);
62
63 protected:
64   cartesian_point _center;
65   double _width_from_center;
66   double _height_from_center;
67 };
68
69 } // namespace.
70
71 #endif
72