Class: Bullet3::Transform
- Inherits:
-
Object
- Object
- Bullet3::Transform
- Defined in:
- lib/bullet3/linear_math/transform.rb
Instance Attribute Summary collapse
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#rotation ⇒ Object
Returns the value of attribute rotation.
Class Method Summary collapse
Instance Method Summary collapse
- #*(other) ⇒ Object
- #basis ⇒ Object
-
#initialize(rotation = Quaternion.identity, origin = Vector3.zero) ⇒ Transform
constructor
A new instance of Transform.
- #inverse ⇒ Object
- #inverse_times(other) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(rotation = Quaternion.identity, origin = Vector3.zero) ⇒ Transform
Returns a new instance of Transform.
11 12 13 14 |
# File 'lib/bullet3/linear_math/transform.rb', line 11 def initialize(rotation = Quaternion.identity, origin = Vector3.zero) @rotation = Quaternion.coerce(rotation) @origin = Vector3.coerce(origin) end |
Instance Attribute Details
#origin ⇒ Object
Returns the value of attribute origin.
5 6 7 |
# File 'lib/bullet3/linear_math/transform.rb', line 5 def origin @origin end |
#rotation ⇒ Object
Returns the value of attribute rotation.
5 6 7 |
# File 'lib/bullet3/linear_math/transform.rb', line 5 def rotation @rotation end |
Class Method Details
.identity ⇒ Object
7 8 9 |
# File 'lib/bullet3/linear_math/transform.rb', line 7 def self.identity new end |
Instance Method Details
#*(other) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/bullet3/linear_math/transform.rb', line 20 def *(other) case other when Transform self.class.new(rotation * other.rotation, transform_vector(other.origin)) else transform_vector(other) end end |
#basis ⇒ Object
16 17 18 |
# File 'lib/bullet3/linear_math/transform.rb', line 16 def basis rotation.to_matrix end |
#inverse ⇒ Object
29 30 31 32 |
# File 'lib/bullet3/linear_math/transform.rb', line 29 def inverse inverse_rotation = rotation.inverse.normalized self.class.new(inverse_rotation, inverse_rotation.to_matrix * -origin) end |
#inverse_times(other) ⇒ Object
34 35 36 |
# File 'lib/bullet3/linear_math/transform.rb', line 34 def inverse_times(other) inverse * other end |
#to_a ⇒ Object
38 39 40 |
# File 'lib/bullet3/linear_math/transform.rb', line 38 def to_a [origin.to_a, rotation.to_a] end |