Class: PhotoscanOutputs::Transform
- Inherits:
-
Object
- Object
- PhotoscanOutputs::Transform
- Defined in:
- lib/photoscan_outputs/camera.rb
Overview
“Transform” is the 3D homogeneous transform from camera to world. That is, T * [0 0 0 1]^T (the origin of the camera frame) yields the camera’s position in world coordinate frame
Or
sR T 0 1
Direct Known Subclasses
Instance Attribute Summary collapse
-
#mat ⇒ Object
readonly
Returns the value of attribute mat.
Class Method Summary collapse
Instance Method Summary collapse
- #*(b) ⇒ Object
- #dump(io = STDOUT) ⇒ Object
-
#initialize(mat, opts = {}) ⇒ Transform
constructor
A new instance of Transform.
- #inv ⇒ Object
- #r_mat ⇒ Object
- #scale ⇒ Object
- #sr_mat ⇒ Object
- #t ⇒ Object
- #t_mat ⇒ Object
Constructor Details
Instance Attribute Details
#mat ⇒ Object (readonly)
Returns the value of attribute mat.
67 68 69 |
# File 'lib/photoscan_outputs/camera.rb', line 67 def mat @mat end |
Class Method Details
.from_xml(xml, global = nil) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/photoscan_outputs/camera.rb', line 111 def self.from_xml( xml, global = nil ) m = xml.text.split(/\s/).map(&:to_f) raise "Not enough elements in matrix" unless m.length == 16 arr = 4.times.map { m.shift(4) } if global IncrementalTransform.new( global.mat, Matrix.rows(arr) ) else Transform.new( Matrix.rows( arr ) ) end end |
Instance Method Details
#*(b) ⇒ Object
103 104 105 |
# File 'lib/photoscan_outputs/camera.rb', line 103 def *(b) mat * b end |
#dump(io = STDOUT) ⇒ Object
107 108 109 |
# File 'lib/photoscan_outputs/camera.rb', line 107 def dump( io = STDOUT ) print_mat( mat, io ) end |
#inv ⇒ Object
99 100 101 |
# File 'lib/photoscan_outputs/camera.rb', line 99 def inv Transform.new mat.inv end |
#r_mat ⇒ Object
86 87 88 89 |
# File 'lib/photoscan_outputs/camera.rb', line 86 def r_mat sc = scale sr_mat.map { |x| x/sc } end |
#scale ⇒ Object
82 83 84 |
# File 'lib/photoscan_outputs/camera.rb', line 82 def scale sr_mat.row_vectors.first.norm end |
#sr_mat ⇒ Object
78 79 80 |
# File 'lib/photoscan_outputs/camera.rb', line 78 def sr_mat Matrix.rows mat.to_a.first(3).map { |row| row.first(3) } end |
#t ⇒ Object
95 96 97 |
# File 'lib/photoscan_outputs/camera.rb', line 95 def t t_mat end |
#t_mat ⇒ Object
91 92 93 |
# File 'lib/photoscan_outputs/camera.rb', line 91 def t_mat Vector[ *( mat.to_a.first(3).map { |row| row.at(3) } ) ] end |