예제 #1
0
파일: vector.py 프로젝트: yishizu/compas
    def transform_collection(collection, X):
        """Transform a collection of vector objects.

        Parameters
        ----------
        collection : list of :class:`compas.geometry.Vector`
            The collection of vectors.

        Examples
        --------
        >>> R = Rotation.from_axis_and_angle(Vector.Zaxis(), radians(90))
        >>> u = Vector(1.0, 0.0, 0.0)
        >>> vectors = [u]
        >>> Vector.transform_collection(vectors, R)
        >>> v = vectors[0]
        >>> v
        Vector(0.000, 1.000, 0.000)
        >>> u is v
        True
        """
        data = transform_vectors(collection, X)
        for vector, xyz in zip(collection, data):
            vector.x = xyz[0]
            vector.y = xyz[1]
            vector.z = xyz[2]
예제 #2
0
파일: vector.py 프로젝트: compas-dev/compas
    def transform(self, T):
        """Transform this vector.

        Parameters
        ----------
        T : :class:`compas.geometry.Transformation` | list[list[float]]
            The transformation.

        Returns
        -------
        None

        Examples
        --------
        >>> from compas.geometry import Rotation
        >>> u = Vector(1.0, 0.0, 0.0)
        >>> R = Rotation.from_axis_and_angle([0.0, 0.0, 1.0], math.radians(90))
        >>> u.transform(R)
        >>> u
        Vector(0.000, 1.000, 0.000)

        """
        point = transform_vectors([self], T)[0]
        self.x = point[0]
        self.y = point[1]
        self.z = point[2]
예제 #3
0
    def transform(self, transformation):
        """Transform the axis in place.

        Parameters
        ----------
        transformation : :class:`Transformation`
            The transformation used to transform the axis.
        """
        xyz = transform_vectors([[self.x, self.y, self.z]],
                                transformation.matrix)
        self.x = xyz[0][0]
        self.y = xyz[0][1]
        self.z = xyz[0][2]
예제 #4
0
    def transformed(self, transformation):
        """Return a transformed copy of the axis.

        Parameters
        ----------
        transformation : :class:`Transformation`
            The transformation used to transform the axis.

        Returns
        -------
        :class:`Axis`
            The transformed axis.
        """
        xyz = transform_vectors([[self.x, self.y, self.z]],
                                transformation.matrix)
        return Vector(xyz[0][0], xyz[0][1], xyz[0][2])
예제 #5
0
def test_transform_vectors(R):
    assert transform_vectors([[1, 2, 3], [5, 6, 7]], R) == [[
        1.0, -3.5781372230600135, 0.44377247881360526
    ], [5.0, -8.946418341978926, 2.227464668699156]]
예제 #6
0
 def transformed(self, transformation):
     xyz = transform_vectors([[self.x, self.y, self.z]],
                             transformation.matrix)
     return Vector(xyz[0][0], xyz[0][1], xyz[0][2])
예제 #7
0
 def transform(self, transformation):
     xyz = transform_vectors([[self.x, self.y, self.z]],
                             transformation.matrix)
     self.x = xyz[0][0]
     self.y = xyz[0][1]
     self.z = xyz[0][2]