Class: CTioga2::Graphics::CoordinateTransforms
- Inherits:
-
Object
- Object
- CTioga2::Graphics::CoordinateTransforms
- Defined in:
- lib/ctioga2/graphics/coordinates.rb
Overview
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.
Instance Attribute Summary collapse
-
#x_log ⇒ Object
Whether to use logarithmic coordinates.
-
#x_offset ⇒ Object
An offset for coordinates.
-
#x_scale ⇒ Object
A scaling factor for coordinates:.
-
#y_log ⇒ Object
Whether to use logarithmic coordinates.
-
#y_offset ⇒ Object
An offset for coordinates.
-
#y_scale ⇒ Object
A scaling factor for coordinates:.
Instance Method Summary collapse
-
#initialize ⇒ CoordinateTransforms
constructor
Creates a CoordinateTransformations object.
-
#transform_2d!(dataset) ⇒ Object
Apply a transformation to a Data::Dataset holding 2D signals.
Constructor Details
#initialize ⇒ CoordinateTransforms
Creates a CoordinateTransformations object.
45 46 |
# File 'lib/ctioga2/graphics/coordinates.rb', line 45 def initialize end |
Instance Attribute Details
#x_log ⇒ Object
Whether to use logarithmic coordinates
42 43 44 |
# File 'lib/ctioga2/graphics/coordinates.rb', line 42 def x_log @x_log end |
#x_offset ⇒ Object
An offset for coordinates
39 40 41 |
# File 'lib/ctioga2/graphics/coordinates.rb', line 39 def x_offset @x_offset end |
#x_scale ⇒ Object
A scaling factor for coordinates:
36 37 38 |
# File 'lib/ctioga2/graphics/coordinates.rb', line 36 def x_scale @x_scale end |
#y_log ⇒ Object
Whether to use logarithmic coordinates
42 43 44 |
# File 'lib/ctioga2/graphics/coordinates.rb', line 42 def y_log @y_log end |
#y_offset ⇒ Object
An offset for coordinates
39 40 41 |
# File 'lib/ctioga2/graphics/coordinates.rb', line 39 def y_offset @y_offset end |
#y_scale ⇒ Object
A scaling factor for coordinates:
36 37 38 |
# File 'lib/ctioga2/graphics/coordinates.rb', line 36 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.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ctioga2/graphics/coordinates.rb', line 50 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 |