Fix CQuat.from_rotvector()

This commit is contained in:
Marek Nečada 2021-02-08 08:47:40 +02:00
parent cf2aca7f03
commit 36c5d5236a
1 changed files with 15 additions and 1 deletions

View File

@ -2,6 +2,7 @@ from .cybspec cimport BaseSpec
from .qpms_cdefs cimport * from .qpms_cdefs cimport *
import cmath import cmath
import math import math
import numpy as np
def complex_crep(complex c, parentheses = False, shortI = True, has_Imaginary = False): def complex_crep(complex c, parentheses = False, shortI = True, has_Imaginary = False):
@ -148,9 +149,22 @@ cdef class CQuat:
@staticmethod @staticmethod
def from_rotvector(vec): def from_rotvector(vec):
'''
Constructs a quaternion representing rotation around a given rotation vector.
Parameters
----------
vec: array_like of shape (3,)
Cartesian components of the rotation vector.
Returns
-------
CQuat
'''
vec = np.array(vec, copy=False)
if vec.shape != (3,): if vec.shape != (3,):
raise ValueError("Single 3d vector expected") raise ValueError("Single 3d vector expected")
res = CQuat() res = CQuat(0,0,0,0)
cdef cart3_t v cdef cart3_t v
v.x = vec[0] v.x = vec[0]
v.y = vec[1] v.y = vec[1]