Module: CVFFI::CvPoint3DMethods

Included in:
CvPoint3DBase, Point3D
Defined in:
lib/opencv-ffi-wrappers/core/point.rb

Overview

Instance Method Summary collapse

Instance Method Details

#*(a) ⇒ Object



176
177
178
179
180
181
182
# File 'lib/opencv-ffi-wrappers/core/point.rb', line 176

def *(a)
  if a.is_a? Point3D
    self.class.new( [ x*a.x, y*a.y, z*a.z ] )
  else
    self.class.new( [ x*a, y*a, z*a.z ] )
  end
end

#+(a) ⇒ Object



192
193
194
195
196
197
198
# File 'lib/opencv-ffi-wrappers/core/point.rb', line 192

def +(a)
  if a.is_a? Point3D
    self.class.new( [ x+a.x, y+a.y, z+a.z ] )
  else
    self.class.new( [ x+a, y+a, z+a ] )
  end
end

#-(a) ⇒ Object



184
185
186
187
188
189
190
# File 'lib/opencv-ffi-wrappers/core/point.rb', line 184

def -(a)
  if a.is_a? Point3D
    self.class.new( [ x.to_f-a.x, y.to_f-a.y, z.to_f-a.z ] )
  else
    self.class.new( [ x.to_f-a, y.to_f-a, z.to_f-a ] )
  end
end

#/(a) ⇒ Object



168
169
170
171
172
173
174
# File 'lib/opencv-ffi-wrappers/core/point.rb', line 168

def /(a)
  if a.is_a? Point3D
    self.class.new( [ x.to_f/a.x.to_f, y.to_f/a.y.to_f, z.to_f/a.z.to_f ] )
  else
    self.class.new( [ x.to_f/a, y.to_f/a, z.to_f/z ] )
  end
end

#==(b) ⇒ Object



200
201
202
# File 'lib/opencv-ffi-wrappers/core/point.rb', line 200

def ==(b)
  @x == b.x and @y == b.y and @z == b.z
end

#===(b) ⇒ Object



203
204
205
# File 'lib/opencv-ffi-wrappers/core/point.rb', line 203

def ===(b)
  @x === b.x and @y === b.y and @z === b.z
end

#got_what_i_need(a) ⇒ Object



164
165
166
# File 'lib/opencv-ffi-wrappers/core/point.rb', line 164

def got_what_i_need(a)
  a.method_defined?(:x) and a.method_defined?(:y) and a.method_defined(:z)
end

#to_a(homogeneous = true) ⇒ Object



212
213
214
215
216
217
218
# File 'lib/opencv-ffi-wrappers/core/point.rb', line 212

def to_a(homogeneous=true)
  if homogeneous
    [@x/@w, @y/@w, @z/@w, 1]
  else
    [@x, @y, @z]
  end
end

#to_Vector(homogeneous = true) ⇒ Object Also known as: to_vector



207
208
209
# File 'lib/opencv-ffi-wrappers/core/point.rb', line 207

def to_Vector( homogeneous = true )
  Vector.elements( to_a(homogeneous) )
end