sisl.Quaternion
- class sisl.Quaternion
Bases:
object
Quaternion object to enable easy rotational quantities.
- Parameters:
*args – For 1 argument, it is the length 4 vector describing the quaternion. For 2 arguments, it is the angle, and vector.
rad – when passing two arguments, for angle and vector, the rad value decides which unit
angle
is in, forrad=True
it is in radians. Otherwise it will be in degrees.
Examples
Construct a quaternion with angle 45°, all 3 are equivalent:
>>> q1 = Quaternion(45, [1, 2, 3], rad=False) >>> q2 = Quaternion(np.pi/4, [1, 2, 3], rad=True) >>> q3 = Quaternion([1, 2, 3], 45, rad=False)
If you have the full quaternion complex number, one can also instantiate it directly without having to consider angles:
>>> q = Quaternion([1, 2, 3, 4])
Methods
angle
([in_rad])Return the angle of this quaternion, in requested unit
conj
()Returns the conjugate of the quaternion
copy
()Return a copy of itself
norm
()Returns the norm of this quaternion
rotate
(v)Rotate a vector v by this quaternion
Attributes
Returns the angle associated with this quaternion (in degrees)
Returns the angle associated with this quaternion (in radians)