class CTioga2::Graphics::CoordinateTransforms

Deals with transforming the coordinates of all datasets

todo

todo Shouldn't this facility be axis-local ? Non-linear transformations definitely belong there as well (and that would be almost trivial to write !).

@todo For now, this is a mess: these things completely mess up the data processing… This is a complex problem:

Attributes

x_log[RW]

Whether to use logarithmic coordinates

x_offset[RW]

An offset for coordinates

x_scale[RW]

A scaling factor for coordinates:

y_log[RW]

Whether to use logarithmic coordinates

y_offset[RW]

An offset for coordinates

y_scale[RW]

A scaling factor for coordinates:

Public Class Methods

new() click to toggle source

Creates a CoordinateTransformations object.

# File lib/ctioga2/graphics/coordinates.rb, line 60
def initialize
end

Public Instance Methods

transform_2d!(dataset) click to toggle source

Apply a transformation to a Data::Dataset holding 2D signals. Modifies the dataset in place.

# File lib/ctioga2/graphics/coordinates.rb, line 65
def transform_2d!(dataset)
  for w in [:x , :y]
    if v = self.send("#{w}_scale") 
      dataset.send(w).apply do |x|
        x.mul!(v)
      end
    end
    if v = self.send("#{w}_offset") 
      dataset.send(w).apply do |x|
        x.add!(v)
      end
    end
    if v = self.send("#{w}_log") 
      dataset.send(w).apply do |x|
        x.safe_log10!
      end
    end
  end
end