Class: XRVG::SimilarMotifIterator

Inherits:
BezierBuilder show all
Defined in:
lib/bezierbuilders.rb

Overview

Similar Motif Iterator

Content

Take a bezier curve as :motif, and a “curvesampler” as a support with sampling description, and iterate motif on each pair computed by sampling

Attributes

attribute :curvesampler, nil, Samplable
attribute :motif, nil, Bezier
attribute :nmotifs, 10

Example

motif        = PicBezier[ :support, [V2D::O, V2D::X], :height, -1.0 ]
curvesampler = bezier.geo( 3.0 )
bezier       = SimilarMotifIterator[ :curvesampler, curvesampler, :motif, motif, :nmotifs, 10 ]

TODO

Represents the basic operator to compute bezier fractal curves !!

Instance Method Summary collapse

Methods inherited from BezierBuilder

[], build, lissage

Instance Method Details

#computeObject

BezierBuilder overloading

Algo

  • sample @nmotif+1 times @curvesampler to get @nmotifs point pairs

  • foreach pair, compute new bezier by calling Bezier.similar on @motif



93
94
95
96
97
98
99
100
101
# File 'lib/bezierbuilders.rb', line 93

def compute
  result = []
  self.curvesampler.samples( self.nmotifs + 1).pairs do |p1,p2|
    Trace("SimilarMotifIterator::compute p1 #{p1.inspect} p2 #{p2.inspect}")
    newbezier = self.motif.similar( (p1..p2) )
    result += newbezier.data
  end
  return result
end