Class: Assimp::Quaternion
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- Assimp::Quaternion
show all
- Extended by:
- StructAccessors
- Defined in:
- lib/assimp/quaternion.rb
Instance Method Summary
collapse
extended, has_ref?, struct_array_attr_accessor, struct_array_attr_checker, struct_array_attr_reader, struct_array_attr_writer, struct_attr_accessor, struct_attr_reader, struct_attr_writer, struct_ref_array_attr_accessor, struct_ref_array_attr_reader, struct_ref_array_attr_writer
Instance Method Details
#*(other) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/assimp/quaternion.rb', line 24
def *(other)
if other.kind_of?(Quaternion)
q = Quaternion::new
q.w = w*other.w - x*other.x - y*other.y - z*other.z
q.x = w*other.x + x*other.w + y*other.z - z*other.y
q.y = w*other.y + y*other.w + z*other.x - x*other.z
q.z = w*other.z + z*other.w + x*other.y - y*other.x
q
elsif other.kind_of?(Vector3D)
v = Vector3D::new
q2 = Quaternion::new
q2.x = other.x
q2.y = other.y
q2.z = other.z
r = self * q2 * conjugate
v.set(r.x, r.y, r.z)
else
raise "Unsupported operand: #{other.inspect}!"
end
end
|
#conjugate ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/assimp/quaternion.rb', line 15
def conjugate
q = Quaternion::new
q.w = w
q.x = -x
q.y = -y
q.z = -z
q
end
|
#to_s ⇒ Object
11
12
13
|
# File 'lib/assimp/quaternion.rb', line 11
def to_s
"{#{w}, #{x}, #{y}, #{z}}"
end
|