Sha256: bdb07ff11ca9fa0ec01cd4f02affc9e06ded8936fd7831fed44f5ad2d6898096

Contents?: true

Size: 844 Bytes

Versions: 16

Compression:

Stored size: 844 Bytes

Contents

# -*- encoding : utf-8 -*-
# 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

16 entries across 16 versions & 1 rubygems

Version Path
tracksperanto-2.12.0 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.11.3 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.11.2 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.11.1 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.11.0 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.10.0 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.9.9 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.9.8 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.9.7 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.9.6 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.9.5 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.9.4 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.9.3 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.9.2 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.9.1 lib/tracksperanto/uv_coordinates.rb
tracksperanto-2.9.0 lib/tracksperanto/uv_coordinates.rb