Sha256: ae7d123a3ed5d98b4b5ad775ff1a2f7eaa521d392033e9c0f9a01910f7993fba

Contents?: true

Size: 816 Bytes

Versions: 20

Compression:

Stored size: 816 Bytes

Contents

# 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.
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

20 entries across 20 versions & 1 rubygems

Version Path
tracksperanto-2.8.6 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.8.5 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.8.4 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.8.2 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.8.1 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.8.0 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.7.0 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.6.3 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.6.2 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.6.1 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.6.0 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.5.0 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.4.1 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.3.3 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.3.2 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.3.1 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.3.0 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.2.4 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.2.2 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.2.0 lib/tracksperanto/uv_coordinates.rb