def Rand(cls, N=1): """ Create SO(3) with random rotation :param N: number of random rotations :type N: int :return: 3x3 rotation matrix :rtype: SO3 instance - ``SO3.Rand()`` is a random SO(3) rotation. - ``SO3.Rand(N)`` is a sequence of N random rotations. :seealso: :func:`spatialmath.quaternion.UnitQuaternion.Rand` """ return cls([tr.q2r(tr.rand()) for i in range(0, N)], check=False)
def SE3(self): """ Convert unit dual quaternion to SE(3) matrix :return: SE(3) matrix :rtype: SE3 Example: .. runblock:: pycon >>> from spatialmath import DualQuaternion, SE3 >>> T = SE3.Rand() >>> print(T) >>> d = UnitDualQuaternion(T) >>> print(d) >>> print(d.T) """ R = base.q2r(self.real.A) t = 2 * self.dual * self.real.conj() return SE3(base.rt2tr(R, t.v))
def Rand(cls, N=1): """ Construct a new SO(3) from random rotation :param N: number of random rotations :type N: int :return: SO(3) rotation matrix :rtype: SO3 instance - ``SO3.Rand()`` is a random SO(3) rotation. - ``SO3.Rand(N)`` is a sequence of N random rotations. Example: .. runblock:: pycon >>> from spatialmath import SO3 >>> x = SO3.Rand() >>> x :seealso: :func:`spatialmath.quaternion.UnitQuaternion.Rand` """ return cls([base.q2r(base.rand()) for _ in range(0, N)], check=False)
def Rand(cls, N=1): """ Construct a new SO(3) from random rotation :param N: number of random rotations :type N: int :return: SO(3) rotation matrix :rtype: SO3 instance - ``SO3.Rand()`` is a random SO(3) rotation. - ``SO3.Rand(N)`` is a sequence of N random rotations. Example:: >>> x = SO3.Rand() >>> x SO3(array([[ 0.1805082 , -0.97959019, 0.08842995], [-0.98357187, -0.17961408, 0.01803234], [-0.00178104, -0.0902322 , -0.99591916]])) :seealso: :func:`spatialmath.quaternion.UnitQuaternion.Rand` """ return cls([tr.q2r(tr.rand()) for _ in range(0, N)], check=False)
def plot(self, *args, **kwargs): tr.trplot(tr.q2r(self._A), *args, **kwargs)