Module: Tracksperanto::UVCoordinates
- Included in:
- Export::SynthEyes, Import::Syntheyes
- Defined in:
- lib/tracksperanto/uv_coordinates.rb
Overview
Syntheyes and some other apps use a relative UV coordinate sustem. For Syntheyes, zero is at the optical center of the image, and goes positive right and up. Since Tracksperanto works in absolute pixels we need to convert to and fro.
Instance Method Summary collapse
-
#absolute_to_uv(abs_x, abs_y, w, h) ⇒ Object
UV coords used by Syntheyes and it’s lens distortion algos.
- #convert_from_uv(absolute_side, uv_value) ⇒ Object
- #convert_to_uv(absolute_value, absolute_side) ⇒ Object
Instance Method Details
#absolute_to_uv(abs_x, abs_y, w, h) ⇒ Object
UV coords used by Syntheyes and it’s lens distortion algos.
8 9 10 |
# File 'lib/tracksperanto/uv_coordinates.rb', line 8 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
18 19 20 21 22 |
# File 'lib/tracksperanto/uv_coordinates.rb', line 18 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
12 13 14 15 16 |
# File 'lib/tracksperanto/uv_coordinates.rb', line 12 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 |