Class: CTioga2::Graphics::CoordinateTransforms

Inherits:
Object
  • Object
show all
Defined in:
lib/ctioga2/graphics/coordinates.rb

Overview

TODO:

For now, this is a mess: these things completely mess up

Deals with transforming the coordinates of all datasets

todo

  • offsets

  • scales

  • x/y log

  • non-linear transformations ?

  • the possibility to provide locations using this.

  • conversion of datasets.

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

the data processing… This is a complex problem:

  • if the Dataset are modified in place, this is a nightmare for data processing

  • on the other hand, if they are not modified in place, this means that things that work on data sets and show things on the plot (think TangentPrimitive, for instance) will have to do additional things to get the target coordinates. This is probably the best way to go, though… This would need some functions to work directly on XY coordinates.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCoordinateTransforms

Creates a CoordinateTransformations object.



60
61
# File 'lib/ctioga2/graphics/coordinates.rb', line 60

def initialize
end

Instance Attribute Details

#x_logObject

Whether to use logarithmic coordinates



57
58
59
# File 'lib/ctioga2/graphics/coordinates.rb', line 57

def x_log
  @x_log
end

#x_offsetObject

An offset for coordinates



54
55
56
# File 'lib/ctioga2/graphics/coordinates.rb', line 54

def x_offset
  @x_offset
end

#x_scaleObject

A scaling factor for coordinates:



51
52
53
# File 'lib/ctioga2/graphics/coordinates.rb', line 51

def x_scale
  @x_scale
end

#y_logObject

Whether to use logarithmic coordinates



57
58
59
# File 'lib/ctioga2/graphics/coordinates.rb', line 57

def y_log
  @y_log
end

#y_offsetObject

An offset for coordinates



54
55
56
# File 'lib/ctioga2/graphics/coordinates.rb', line 54

def y_offset
  @y_offset
end

#y_scaleObject

A scaling factor for coordinates:



51
52
53
# File 'lib/ctioga2/graphics/coordinates.rb', line 51

def y_scale
  @y_scale
end

Instance Method Details

#transform_2d!(dataset) ⇒ Object

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



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# 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