#ifndef REGULARPOLYGONSURFACE_HPP #define REGULARPOLYGONSURFACE_HPP // // $Id: RegularPolygonSurface.hpp,v 1.4 2000/12/05 16:52:41 hobbs Exp $ // // File: RegularPolygonSurface.hpp // Purpose: // Created: 26-APR-1999 // // $Revision: 1.4 $ // // // Include files #include #include #include namespace dgs { /** A Polygon A regular polygon is a plane surface with ns edges all having the same length. Inner and outer lengths are provided to make annular polygons. The default orientation is in the x-y plane, with the center of the first side at phi=0. */ class RegularPolygonSurface: public GeometryElement { public: /// Default constructor RegularPolygonSurface(): _cvers("$Revision: 1.4 $") {} /// Construct giving the number of sides and lengths of inner and outer edge RegularPolygonSurface(const int ns, const double lenin, const double lenout): d_ns(ns), d_lenin(lenin), d_lenout(lenout), _cvers("$Revision: 1.4 $") {} /// Convert local point to global one. virtual SpacePoint local_to_global(const CartesianCoordinate& lpt) const; /// Convert Matrix in local coordinates to matrix in global coordinates virtual MatrixD local_to_global(const CartesianMatrix& theMatrix) const; /// Convert global point to local one. virtual CartesianCoordinate global_to_local(const SpacePoint& gpt) const; /// Resize plane by given amounts in inner and outer lengths bool resize(const double dlin, const double dlout); /// Position child surface at specified local coordinate. bool position_child_at(const CartesianCoordinate& lpt, GeometryElement& kid); /// Get number of sides int get_sides() const { return d_ns; } /// Get inner side length double get_inner_length() const { return d_lenin; } /// Get outer side length double get_outer_length() const { return d_lenout; } /// Get inscribed circle radius, inner edge double get_inner_radius() const; /// Get inscribed circle radius, outer edge double get_outer_radius() const; /// Get source code version. Kept to allow following code changes const std::string& code_version() const { return _cvers; } /// Checks that a point is actually in the area of the polygon bool point_ok(const CartesianCoordinate& lpt) const; private: /// Number of sides int d_ns; /// Side lengths at inner/outer surface double d_lenin,d_lenout; /// Support for positioning children. Xform of position to coordinate CartesianCoordinate xform_to_local(const GeometryXform& xf) const; /// Support for positioning children. Local Coordinate of position to xform. GeometryXform local_to_xform(const CartesianCoordinate& lpt) const; /// RCS version std::string _cvers; // Replaced at checkout public: D0_OBJECT_SETUP(RegularPolygonSurface); }; /// Stream insertion operator. ///std::ostream& operator<<(std::ostream& os, const RegularPolygonSurface& me); } // end of namespace dgs #endif //REGULARPOLYGONSURFACE_HPP