Class: Kamelopard::Functions::PointSplineFunction

Inherits:
SplineFunction show all
Defined in:
lib/kamelopard/spline.rb

Overview

Spline that takes Points as control points

Instance Attribute Summary

Attributes inherited from SplineFunction

#control_points, #tension, #total_dur

Attributes inherited from FunctionMultiDim

#ndims

Attributes inherited from Function

#append, #compose, #end, #max, #min, #start, #verbose

Instance Method Summary collapse

Methods inherited from FunctionMultiDim

#compose=

Methods inherited from Function

#get_value, interpolate

Constructor Details

#initialize(tension = 0.5) ⇒ PointSplineFunction

Returns a new instance of PointSplineFunction.



118
119
120
121
# File 'lib/kamelopard/spline.rb', line 118

def initialize(tension = 0.5)
    @fields = [:longitude, :latitude, :altitude]
    super(@fields.length, tension)
end

Instance Method Details

#add_control_point(point, dur) ⇒ Object



123
124
125
126
127
128
129
130
131
132
# File 'lib/kamelopard/spline.rb', line 123

def add_control_point(point, dur)
    super((
        @fields.collect { |f|
            begin
                point.method(f).call
            rescue
                0
            end
         }), dur)
end

#run_function(x) ⇒ Object



134
135
136
137
# File 'lib/kamelopard/spline.rb', line 134

def run_function(x)
    res = super(x)
    return point(h[0], h[1], h[2], @first_control_point.altitudeMode)
end