Class: Box2D::Vec2

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/box2d_math_functions.rb,
lib/box2d_helper.rb

Overview

Struct

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.copy_from(vec) ⇒ Object



40
41
42
# File 'lib/box2d_helper.rb', line 40

def self.copy_from(vec)
  Vec2.create_as(vec[:x], vec[:y])
end

.create_as(_x_, _y_) ⇒ Object



31
32
33
34
35
36
# File 'lib/box2d_math_functions.rb', line 31

def self.create_as(_x_, _y_)
  instance = Vec2.new
  instance[:x] = _x_
  instance[:y] = _y_
  instance
end

Instance Method Details

#add(x, y) ⇒ Object



50
51
52
53
54
# File 'lib/box2d_helper.rb', line 50

def add(x, y)
  self[:x] = self[:x] + x
  self[:y] = self[:y] + y
  self
end

#add_vector(v) ⇒ Object



56
57
58
59
60
# File 'lib/box2d_helper.rb', line 56

def add_vector(v)
  self[:x] = self[:x] + v[:x]
  self[:y] = self[:y] + v[:y]
  self
end

#set(x, y) ⇒ Object



44
45
46
47
48
# File 'lib/box2d_helper.rb', line 44

def set(x, y)
  self[:x] = x
  self[:y] = y
  self
end

#to_aObject



62
63
64
# File 'lib/box2d_helper.rb', line 62

def to_a
  [x, y]
end

#xObject



27
# File 'lib/box2d_math_functions.rb', line 27

def x = self[:x]

#x=(v) ⇒ Object



28
# File 'lib/box2d_math_functions.rb', line 28

def x=(v) self[:x] = v end

#yObject



29
# File 'lib/box2d_math_functions.rb', line 29

def y = self[:y]

#y=(v) ⇒ Object



30
# File 'lib/box2d_math_functions.rb', line 30

def y=(v) self[:y] = v end