Class: Geometry::DiameterRegularPolygon
- Inherits:
-
RegularPolygon
- Object
- Polyline
- Polygon
- RegularPolygon
- Geometry::DiameterRegularPolygon
- Defined in:
- lib/geometry/regular_polygon.rb
Instance Attribute Summary collapse
-
#diameter ⇒ Number
readonly
The RegularPolygon‘s diameter.
Attributes inherited from RegularPolygon
Attributes inherited from Polyline
Accessors collapse
-
#radius ⇒ Number
The RegularPolygon‘s radius.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(edge_count, center, diameter) ⇒ RegularPolygon
constructor
Construct a new RegularPolygon from a centerpoint and a diameter.
Methods inherited from RegularPolygon
Methods included from ClusterFactory
Methods inherited from Polygon
#<=>, #clockwise?, #convex, #offset_bisectors, #outset, #reverse, #union, #wrap
Methods inherited from Polyline
Constructor Details
#initialize(edge_count, center, diameter) ⇒ RegularPolygon
Construct a new RegularPolygon from a centerpoint and a diameter
86 87 88 89 90 |
# File 'lib/geometry/regular_polygon.rb', line 86 def initialize(edge_count, center, diameter) @center = center ? Point[center] : nil @edge_count = edge_count @diameter = diameter end |
Instance Attribute Details
#diameter ⇒ Number (readonly)
Returns The RegularPolygon‘s diameter.
79 80 81 |
# File 'lib/geometry/regular_polygon.rb', line 79 def diameter @diameter end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
92 93 94 |
# File 'lib/geometry/regular_polygon.rb', line 92 def eql?(other) (self.center == other.center) && (self.edge_count == other.edge_count) && (self.diameter == other.diameter) end |
#radius ⇒ Number
Returns The RegularPolygon‘s radius.
99 100 101 |
# File 'lib/geometry/regular_polygon.rb', line 99 def radius @diameter/2 end |