Class: FlameChannelParser::Segments::LinearSegment

Inherits:
ConstantSegment show all
Defined in:
lib/segments.rb

Overview

This segment linearly interpolates

Constant Summary

Constants inherited from ConstantSegment

ConstantSegment::NEG_INF, ConstantSegment::POS_INF

Instance Attribute Summary

Attributes inherited from ConstantSegment

#end_frame, #start_frame

Instance Method Summary collapse

Methods inherited from ConstantSegment

#defines?

Constructor Details

#initialize(from_frame, to_frame, value1, value2) ⇒ LinearSegment

:nodoc:



33
34
35
36
# File 'lib/segments.rb', line 33

def initialize(from_frame, to_frame, value1, value2)
  @vint = (value2 - value1)
  super(from_frame, to_frame, value1)
end

Instance Method Details

#value_at(frame) ⇒ Object

Returns the value at this time T



39
40
41
42
# File 'lib/segments.rb', line 39

def value_at(frame)
  on_t_interval = (frame - @start_frame).to_f / (@end_frame - @start_frame)
  @v1 + (on_t_interval * @vint)
end