Class: RegularPolygon
Instance Attribute Summary collapse
-
#radius ⇒ Object
readonly
Returns the value of attribute radius.
-
#sides ⇒ Object
readonly
Returns the value of attribute sides.
Attributes inherited from Polygon
Instance Method Summary collapse
-
#initialize(sides, radius) ⇒ RegularPolygon
constructor
A new instance of RegularPolygon.
Methods inherited from Shape
#*, #+, #-, #align, #back, #bbox, #bottom, #center, #cx, #cy, #cz, #extrude, #front, #left, #maxx, #maxy, #maxz, #minx, #miny, #minz, #mirror, #mirror_x, #mirror_y, #mirror_z, #move, #move_x, #move_y, #move_z, #render, #revolve, #right, #rot_x, #rot_y, #rot_z, #rotate, #scale, #scale_x, #scale_y, #scale_z, #top, #transform, #xcenter, #xsize, #ycenter, #ysize, #zcenter, #zsize, #~@
Constructor Details
#initialize(sides, radius) ⇒ RegularPolygon
Returns a new instance of RegularPolygon.
416 417 418 419 420 421 422 423 |
# File 'lib/rcad.rb', line 416 def initialize(sides, radius) @sides = sides @radius = radius angles = (1..sides).map { |i| i * 2 * Math::PI / sides } points = angles.map { |a| to_polar(radius, a) } super(points) end |
Instance Attribute Details
#radius ⇒ Object (readonly)
Returns the value of attribute radius.
414 415 416 |
# File 'lib/rcad.rb', line 414 def radius @radius end |
#sides ⇒ Object (readonly)
Returns the value of attribute sides.
414 415 416 |
# File 'lib/rcad.rb', line 414 def sides @sides end |