Module: Tracksperanto::UVCoordinates

Included in:
Export::SynthEyes, Import::Syntheyes
Defined in:
lib/tracksperanto/uv_coordinates.rb

Overview

Y down X right, 0 is center and values are UV float -1 to 1, doubled

Instance Method Summary collapse

Instance Method Details

#absolute_to_uv(abs_x, abs_y, w, h) ⇒ Object

UV coords used by Syntheyes and it’s lens distortion algos.



5
6
7
# File 'lib/tracksperanto/uv_coordinates.rb', line 5

def absolute_to_uv(abs_x, abs_y, w, h)
  [convert_to_uv(abs_x, w), convert_to_uv(abs_y, h) * -1]
end

#convert_from_uv(absolute_side, uv_value) ⇒ Object



15
16
17
18
19
# File 'lib/tracksperanto/uv_coordinates.rb', line 15

def convert_from_uv(absolute_side, uv_value)
  # First, start from zero (-.1 becomes .4)
  value_off_corner = (uv_value.to_f / 2) + 0.5
  absolute_side * value_off_corner
end

#convert_to_uv(absolute_value, absolute_side) ⇒ Object



9
10
11
12
13
# File 'lib/tracksperanto/uv_coordinates.rb', line 9

def convert_to_uv(absolute_value, absolute_side)
  x = (absolute_value / absolute_side.to_f) - 0.5
  # .2 to -.3, y is reversed and coords are double
  x * 2
end