Class: Artoo::Drivers::Leapmotion::Hand
- Inherits:
-
Object
- Object
- Artoo::Drivers::Leapmotion::Hand
- Defined in:
- lib/artoo/drivers/leapmotion/hand.rb
Class Method Summary collapse
-
.list(data) ⇒ Object
Public: Iterates through LeapMotion frame data, extracting all Hand JSON into new Leapmotion::Hand objects.
Instance Method Summary collapse
-
#initialize(data) ⇒ Hand
constructor
Public: initialize.
-
#palm_x ⇒ Object
Public: Palm x position.
-
#palm_y ⇒ Object
Public: Palm y position.
-
#palm_z ⇒ Object
Public: Palm z position.
-
#rotation ⇒ Object
Public: Rotation.
Constructor Details
#initialize(data) ⇒ Hand
Public: initialize
frame - params
Returns nil
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/artoo/drivers/leapmotion/hand.rb', line 21 def initialize(data) data.each do |key, value| instance_variable_set "@#{key}", value self.class.send( :define_method, key.to_sym, lambda { instance_variable_get("@#{key}") } ) end end |
Class Method Details
.list(data) ⇒ Object
Public: Iterates through LeapMotion frame data, extracting all Hand JSON into new Leapmotion::Hand objects.
data - a LeapMotion frame that may or may not contain hand data
Returns an array containing all Hands found in the frame
12 13 14 15 |
# File 'lib/artoo/drivers/leapmotion/hand.rb', line 12 def self.list(data) return [] unless data["hands"] data["hands"].map { |hand| Artoo::Drivers::Leapmotion::Hand.new hand } end |
Instance Method Details
#palm_x ⇒ Object
Public: Palm x position
Returns nil
35 36 37 |
# File 'lib/artoo/drivers/leapmotion/hand.rb', line 35 def palm_x palmPosition[0] if palmPosition end |
#palm_y ⇒ Object
Public: Palm y position
Returns nil
42 43 44 |
# File 'lib/artoo/drivers/leapmotion/hand.rb', line 42 def palm_y palmPosition[2] if palmPosition end |
#palm_z ⇒ Object
Public: Palm z position
Returns nil
49 50 51 |
# File 'lib/artoo/drivers/leapmotion/hand.rb', line 49 def palm_z palmPosition[1] if palmPosition end |
#rotation ⇒ Object
Public: Rotation
Returns nil
56 57 58 59 60 61 62 |
# File 'lib/artoo/drivers/leapmotion/hand.rb', line 56 def rotation { axis: @r[0], angle: @r[1], matrix: @r[2] } end |