Class: TuioPoint

Inherits:
Object show all
Defined in:
lib/tuio-ruby/tuio_point.rb

Direct Known Subclasses

TuioContainer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x_pos, y_pos) ⇒ TuioPoint

Returns a new instance of TuioPoint.



4
5
6
# File 'lib/tuio-ruby/tuio_point.rb', line 4

def initialize( x_pos, y_pos )
  @x_pos, @y_pos = x_pos, y_pos
end

Instance Attribute Details

#updated_atObject

Returns the value of attribute updated_at.



2
3
4
# File 'lib/tuio-ruby/tuio_point.rb', line 2

def updated_at
  @updated_at
end

#x_posObject

Returns the value of attribute x_pos.



2
3
4
# File 'lib/tuio-ruby/tuio_point.rb', line 2

def x_pos
  @x_pos
end

#y_posObject

Returns the value of attribute y_pos.



2
3
4
# File 'lib/tuio-ruby/tuio_point.rb', line 2

def y_pos
  @y_pos
end

Instance Method Details

#degrees_to(another_point) ⇒ Object



31
32
33
# File 'lib/tuio-ruby/tuio_point.rb', line 31

def degrees_to( another_point )
  ( radians_to( another_point ) / Math::PI ) * 180.0
end

#distance_to(another_point) ⇒ Object



14
15
16
17
18
19
# File 'lib/tuio-ruby/tuio_point.rb', line 14

def distance_to( another_point )
  dx = @x_pos - another_point.x_pos
  dy = @y_pos - another_point.y_pos
  
  Math.sqrt( dx*dx + dy*dy )
end

#eql?(another_point) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/tuio-ruby/tuio_point.rb', line 35

def eql?( another_point )
  @x_pos == another_point.x_pos &&
  @y_pos == another_point.y_pos
end

#radians_to(another_point) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/tuio-ruby/tuio_point.rb', line 21

def radians_to( another_point )
  side =   another_point.x_pos - @x_pos
  height = another_point.y_pos - @y_pos
  distance = distance_to( another_point )
  
  angle = Math.asin( side / distance ) + Math::PI / 2 
  angle = 2.0 * Math.PI - angle if height < 0 
  angle
end

#update(x_pos, y_pos) ⇒ Object



8
9
10
11
12
# File 'lib/tuio-ruby/tuio_point.rb', line 8

def update( x_pos, y_pos )
  @x_pos, @y_pos = x_pos, y_pos

  clear_update_time
end