class Straightedge::Figures::Hexagon
Attributes
scale[RW]
Public Class Methods
new(location: Straightedge::ORIGIN, color: :white, scale: 1.0)
click to toggle source
Calls superclass method
Straightedge::Figures::Figure::new
# File lib/straightedge/figures/hexagon.rb, line 5 def initialize(location: Straightedge::ORIGIN, color: :white, scale: 1.0) super(location: location, color: color) @scale = scale @marks = corners end
Public Instance Methods
center_quad()
click to toggle source
# File lib/straightedge/figures/hexagon.rb, line 20 def center_quad [corners[0], corners[2], corners[3], corners[5]] end
corners()
click to toggle source
# File lib/straightedge/figures/hexagon.rb, line 24 def corners Array.new(6) do |i| angle = 2 * Math::PI / 6 * (i+2) x_i = x + scale * Math.cos(angle) y_i = y + scale * Math.sin(angle) [x_i, y_i] end end
left_triangle()
click to toggle source
lots of magic hereā¦
# File lib/straightedge/figures/hexagon.rb, line 12 def left_triangle corners[0..2] end
right_triangle()
click to toggle source
# File lib/straightedge/figures/hexagon.rb, line 16 def right_triangle corners[3..5] end