示例#1
0
    def from_data(cls, data):
        """Construct a circle from its data representation.

        Parameters
        ----------
        data : :obj:`dict`
            The data dictionary.

        Returns
        -------
        Circle
            The constructed circle.

        Examples
        --------
        >>> from compas.geometry import Circle
        >>> from compas.geometry import Plane
        >>> data = {'plane': Plane.worldXY().data, 'radius': 5.}
        >>> circle = Circle.from_data(data)

        """
        circle = cls(Plane.worldXY(), 1)
        circle.data = data
        return circle
示例#2
0
 def plane(self, plane):
     self._plane = Plane(plane[0], plane[1])
示例#3
0
 def data(self, data):
     self.plane = Plane.from_data(data['plane'])
     self.radius = data['radius']
示例#4
0
        >>> T = Transformation.from_frame(frame)
        >>> circle_transformed = circle.transformed(T)

        """
        circle = self.copy()
        circle.transform(transformation)
        return circle


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":
    from compas.geometry import Frame
    from compas.geometry import Transformation
    circle = Circle(Plane.worldXY(), 5)
    frame = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
    print(frame.normal)
    T = Transformation.from_frame(frame)
    circle.transform(T)
    print(circle)

    print(Plane.worldXY().data)
    data = {'plane': Plane.worldXY().data, 'radius': 5.}
    circle = Circle.from_data(data)
    print(circle)

    import doctest
    doctest.testmod()