Class: Bayonetta::Bone
- Inherits:
-
Object
- Object
- Bayonetta::Bone
- Defined in:
- lib/bayonetta/bone.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#flag ⇒ Object
Returns the value of attribute flag.
-
#index ⇒ Object
Returns the value of attribute index.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#position ⇒ Object
Returns the value of attribute position.
-
#relative_position ⇒ Object
Returns the value of attribute relative_position.
-
#symmetric ⇒ Object
Returns the value of attribute symmetric.
Instance Method Summary collapse
- #depth ⇒ Object
- #distance(other) ⇒ Object
-
#initialize(position) ⇒ Bone
constructor
A new instance of Bone.
- #inspect ⇒ Object
- #parents ⇒ Object
- #to_s ⇒ Object
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
#children ⇒ Object
Returns the value of attribute children.
5 6 7 |
# File 'lib/bayonetta/bone.rb', line 5 def children @children end |
#flag ⇒ Object
Returns the value of attribute flag.
10 11 12 |
# File 'lib/bayonetta/bone.rb', line 10 def flag @flag end |
#index ⇒ Object
Returns the value of attribute index.
6 7 8 |
# File 'lib/bayonetta/bone.rb', line 6 def index @index end |
#parent ⇒ Object
Returns the value of attribute parent.
4 5 6 |
# File 'lib/bayonetta/bone.rb', line 4 def parent @parent end |
#position ⇒ Object
Returns the value of attribute position.
7 8 9 |
# File 'lib/bayonetta/bone.rb', line 7 def position @position end |
#relative_position ⇒ Object
Returns the value of attribute relative_position.
8 9 10 |
# File 'lib/bayonetta/bone.rb', line 8 def relative_position @relative_position end |
#symmetric ⇒ Object
Returns the value of attribute symmetric.
9 10 11 |
# File 'lib/bayonetta/bone.rb', line 9 def symmetric @symmetric end |
Instance Method Details
#depth ⇒ Object
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 |
#inspect ⇒ Object
33 34 35 |
# File 'lib/bayonetta/bone.rb', line 33 def inspect to_s end |
#parents ⇒ Object
46 47 48 49 |
# File 'lib/bayonetta/bone.rb', line 46 def parents return [] unless parent return [parent] + parent.parents end |
#to_s ⇒ Object
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 |