class Draught::ArcBuilder::SegmentBuilder
@api: private Based on learnings from www.tinaja.com/glib/bezcirc2.pdf, via www.whizkidtech.redprince.net/bezier/circle/
Attributes
radius[R]
start[R]
sweep[R]
Public Class Methods
new(sweep, start, radius)
click to toggle source
# File lib/draught/arc_builder.rb, line 106 def initialize(sweep, start, radius) @sweep, @start, @radius = sweep, start, radius end
Public Instance Methods
cubic_bezier()
click to toggle source
# File lib/draught/arc_builder.rb, line 118 def cubic_bezier @cubic_bezier ||= CubicBezier.new({ end_point: end_point, control_point_1: control_point_1, control_point_2: control_point_2 }) end
end_point()
click to toggle source
# File lib/draught/arc_builder.rb, line 114 def end_point @end_point ||= Point.new(x0, y0).transform(transform) end
first_point()
click to toggle source
# File lib/draught/arc_builder.rb, line 110 def first_point @first_point ||= Point.new(x0, -y0).transform(transform) end
Private Instance Methods
control_point_1()
click to toggle source
# File lib/draught/arc_builder.rb, line 126 def control_point_1 Point.new(x1, -y1).transform(transform) end
control_point_2()
click to toggle source
# File lib/draught/arc_builder.rb, line 130 def control_point_2 Point.new(x1, y1).transform(transform) end
sweep_offset()
click to toggle source
# File lib/draught/arc_builder.rb, line 140 def sweep_offset @sweep_offset ||= sweep / 2.0 end
transform()
click to toggle source
# File lib/draught/arc_builder.rb, line 134 def transform @transform ||= Transformations::Composer.compose( Transformations.rotate(start + sweep_offset), Transformations.scale(radius) ) end
x0()
click to toggle source
# File lib/draught/arc_builder.rb, line 144 def x0 Math.cos(sweep_offset) end
x1()
click to toggle source
# File lib/draught/arc_builder.rb, line 152 def x1 (4 - x0)/3.0 end
y0()
click to toggle source
# File lib/draught/arc_builder.rb, line 148 def y0 Math.sin(sweep_offset) end
y1()
click to toggle source
# File lib/draught/arc_builder.rb, line 156 def y1 ((1 - x0) * (3 - x0)) / (3 * y0) end