Class: Bayonetta::Bone

Inherits:
Object
  • Object
show all
Defined in:
lib/bayonetta/bone.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(position) ⇒ Bone

Returns a new instance of Bone.



11
12
13
14
15
16
17
18
19
# File 'lib/bayonetta/bone.rb', line 11

def initialize( position )
  @position = position
  @children = []
  @parent = nil
  @relative_position = nil
  @symmetric = nil
  @flag = nil
  @index = nil
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



5
6
7
# File 'lib/bayonetta/bone.rb', line 5

def children
  @children
end

#flagObject

Returns the value of attribute flag.



10
11
12
# File 'lib/bayonetta/bone.rb', line 10

def flag
  @flag
end

#indexObject

Returns the value of attribute index.



6
7
8
# File 'lib/bayonetta/bone.rb', line 6

def index
  @index
end

#parentObject

Returns the value of attribute parent.



4
5
6
# File 'lib/bayonetta/bone.rb', line 4

def parent
  @parent
end

#positionObject

Returns the value of attribute position.



7
8
9
# File 'lib/bayonetta/bone.rb', line 7

def position
  @position
end

#relative_positionObject

Returns the value of attribute relative_position.



8
9
10
# File 'lib/bayonetta/bone.rb', line 8

def relative_position
  @relative_position
end

#symmetricObject

Returns the value of attribute symmetric.



9
10
11
# File 'lib/bayonetta/bone.rb', line 9

def symmetric
  @symmetric
end

Instance Method Details

#depthObject



21
22
23
24
25
26
27
# File 'lib/bayonetta/bone.rb', line 21

def depth
  if parent then
    return parent.depth + 1
  else
    return 0
  end
end

#distance(other) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/bayonetta/bone.rb', line 37

def distance(other)
  d = (@position.x - other.position.x)**2 +
      (@position.y - other.position.y)**2 +
      (@position.z - other.position.z)**2
  d = Math::sqrt(d)
  dd = (depth - other.depth).abs
  [d, dd]
end

#inspectObject



33
34
35
# File 'lib/bayonetta/bone.rb', line 33

def inspect
  to_s
end

#parentsObject



46
47
48
49
# File 'lib/bayonetta/bone.rb', line 46

def parents
  return [] unless parent
  return [parent] + parent.parents
end

#to_sObject



29
30
31
# File 'lib/bayonetta/bone.rb', line 29

def to_s
  "<#{@index}#{@parent ? " (#{@parent.index})" : ""}: #{@position.x}, #{@position.y}, #{@position.z}, d: #{depth}>"
end