class Assimp::Quaternion

Public Instance Methods

*(other) click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/assimp/quaternion.rb, line 11
def to_s
  "{#{w}, #{x}, #{y}, #{z}}"
end