示例#1
0
文件: line.py 项目: yijiangh/compas
    def transform(self, matrix):
        """Transform this ``Plane`` using a given transformation matrix.

        Parameters
        ----------
        matrix : list of list
            The transformation matrix.

        """
        self.start = transform_points([self.start], matrix)[0]
        self.end = transform_points([self.end], matrix)[0]
示例#2
0
    def transform_collection(collection, X):
        """Transform a collection of ``Point`` objects.

        Parameters
        ----------
        collection : list of compas.geometry.Point
            The collection of points.

        Returns
        -------
        None
            The points are modified in-place.

        Examples
        --------
        >>> T = Translation([1.0, 2.0, 3.0])
        >>> a = Point(0.0, 0.0, 0.0)
        >>> points = [a]
        >>> Point.transform_collection(points, T)
        >>> b = points[0]
        >>> b
        Point(1.000, 2.000, 3.000)
        >>> a is b
        True

        """
        data = transform_points(collection, X)
        for point, xyz in zip(collection, data):
            point.x = xyz[0]
            point.y = xyz[1]
            point.z = xyz[2]
示例#3
0
    def transform(self, matrix):
        """Transform this ``Polyline`` using a given transformation matrix.

        Parameters
        ----------
        matrix : list of list
            The transformation matrix.

        """
        for index, point in enumerate(transform_points(self.points, matrix)):
            self.points[index].x = point[0]
            self.points[index].y = point[1]
            self.points[index].z = point[2]
示例#4
0
    def transform(self, T):
        """Transform this ``Point`` using a given transformation matrix.

        Parameters
        ----------
        T : list of list or compas.geometry.Transformation
            The transformation matrix.

        """
        point = transform_points([self], T)[0]
        self.x = point[0]
        self.y = point[1]
        self.z = point[2]
示例#5
0
文件: point.py 项目: sehlstrom/compas
    def transform(self, matrix):
        """Transform this ``Point`` using a given transformation matrix.

        Parameters
        ----------
        matrix : list of list
            The transformation matrix.

        """
        point = transform_points([self], matrix)[0]
        self.x = point[0]
        self.y = point[1]
        self.z = point[2]
示例#6
0
文件: plane.py 项目: sehlstrom/compas
    def transform(self, matrix):
        """Transform this ``Plane`` using a given transformation matrix.

        Parameters
        ----------
        matrix : list of list
            The transformation matrix.

        """
        point = transform_points([self.point], matrix)
        normal = transform_vectors([self.normal], matrix)
        self.point.x = point[0]
        self.point.y = point[1]
        self.point.z = point[2]
        self.normal.x = normal[0]
        self.normal.y = normal[1]
        self.normal.z = normal[2]
示例#7
0
def rotate_points(points, angle, axis=None, origin=None):
    """Rotates points around an arbitrary axis in 3D.

    Parameters
    ----------
    points : list of point
        A list of points.
    angle : float
        The angle of rotation in radians.
    axis : vector, optional
        The rotation axis.
        Default is ``[0.0, 0.0, 1.0]``
    origin : point, optional
        The origin of the rotation axis.
        Default is ``[0.0, 0.0, 0.0]``.

    Returns
    -------
    list of point
        The rotated points

    Examples
    --------
    >>>

    Notes
    -----
    For more info, see [1]_.

    References
    ----------
    .. [1] Wikipedia. *Rotation matrix*.
           Available at: https://en.wikipedia.org/wiki/Rotation_matrix.

    """
    if axis is None:
        axis = [0.0, 0.0, 1.0]
    if origin is None:
        origin = [0.0, 0.0, 0.0]

    R = matrix_from_axis_and_angle(axis, angle, origin)
    points = transform_points(points, R)
    return points
示例#8
0
def scale_points_xy(points, scale):
    """Scale points in the XY plane.

    Parameters
    ----------
    points : list of point
        A list of points.
    scale : float
        A scaling factor.

    Returns
    -------
    list of point
        The scaled points in the XY plane (Z=0).

    Examples
    --------
    >>> 

    """
    T = matrix_from_scale_factors([scale, scale, 0])
    return transform_points(points, T)
示例#9
0
def test_transform_points(T):
    assert transform_points([[0, 0, 1], [1, 0, 0]], T) == [[1.0, 2.0, 4.0],
                                                           [2.0, 2.0, 3.0]]