From 36c5d5236a73addb4746b9affd9ba95123b45461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Mon, 8 Feb 2021 08:47:40 +0200 Subject: [PATCH] Fix CQuat.from_rotvector() --- qpms/cyquaternions.pyx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/qpms/cyquaternions.pyx b/qpms/cyquaternions.pyx index 823b82c..0797146 100644 --- a/qpms/cyquaternions.pyx +++ b/qpms/cyquaternions.pyx @@ -2,6 +2,7 @@ from .cybspec cimport BaseSpec from .qpms_cdefs cimport * import cmath import math +import numpy as np def complex_crep(complex c, parentheses = False, shortI = True, has_Imaginary = False): @@ -148,9 +149,22 @@ cdef class CQuat: @staticmethod 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,): raise ValueError("Single 3d vector expected") - res = CQuat() + res = CQuat(0,0,0,0) cdef cart3_t v v.x = vec[0] v.y = vec[1]