Sha256: 0fe4fe708523b762e888f5b7f441a50fa6f98750df060d4e5740eac601361817

Contents?: true

Size: 647 Bytes

Versions: 32

Compression:

Stored size: 647 Bytes

Contents

# Y down X right, 0 is center and values are UV float -1 to 1, doubled
module Tracksperanto::UVCoordinates
  
  # UV coords used by Syntheyes and it's lens distortion algos.
  def absolute_to_uv(abs_x, abs_y, w, h)
    [convert_to_uv(abs_x, w), convert_to_uv(abs_y, h) * -1]
  end
  
  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
  
  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
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
tracksperanto-1.7.3 lib/tracksperanto/uv_coordinates.rb
tracksperanto-1.7.2 lib/tracksperanto/uv_coordinates.rb
tracksperanto-1.7.1 lib/tracksperanto/uv_coordinates.rb
tracksperanto-1.7.0 lib/tracksperanto/uv_coordinates.rb
tracksperanto-1.6.9 lib/tracksperanto/uv_coordinates.rb
tracksperanto-1.6.8 lib/tracksperanto/uv_coordinates.rb
tracksperanto-1.6.7 lib/tracksperanto/uv_coordinates.rb
tracksperanto-1.6.6 lib/tracksperanto/uv_coordinates.rb
tracksperanto-1.6.5 lib/tracksperanto/uv_coordinates.rb
tracksperanto-1.6.4 lib/tracksperanto/uv_coordinates.rb
tracksperanto-1.6.3 lib/tracksperanto/uv_coordinates.rb
tracksperanto-1.6.2 lib/tracksperanto/uv_coordinates.rb