Exemplo n.º 1
0
    def from_data(cls, data):
        """Construct a cylinder from its data representation.

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

        Returns
        -------
        Cylinder
            The constructed cylinder.

        Examples
        --------
        >>> from compas.geometry import Cylinder
        >>> from compas.geometry import Circle
        >>> from compas.geometry import Plane
        >>> data = {'circle': Circle(Plane.worldXY(), 5).data, 'height': 7.}
        >>> cylinder = Cylinder.from_data(data)

        """
        cylinder = cls(Circle(Plane.worldXY(), 1), 1)
        cylinder.data = data
        return cylinder
Exemplo n.º 2
0
    def from_data(cls, data):
        """Construct a ellipse from its data representation.

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

        Returns
        -------
        :class:`compas.geometry.Ellipse`
            The constructed ellipse.

        Examples
        --------
        >>> from compas.geometry import Ellipse
        >>> data = {'plane': {'point': [0.0, 0.0, 0.0], 'normal': [0.0, 0.0, 1.0]}, 'major': 2.0, 'minor': 1.0}
        >>> ellipse = Ellipse.from_data(data)
        """
        return cls(Plane.from_data(data['plane']), data['minor'], data['minor'])
Exemplo n.º 3
0
    def from_data(cls, data):
        """Construct a circle from its data representation.

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

        Returns
        -------
        :class:`compas.geometry.Circle`
            The constructed circle.

        Examples
        --------
        >>> from compas.geometry import Circle
        >>> data = {'plane': {'point': [0.0, 0.0, 0.0], 'normal': [0.0, 0.0, 1.0]}, 'radius': 5.}
        >>> circle = Circle.from_data(data)
        """
        return cls(Plane.from_data(data['plane']), data['radius'])
Exemplo n.º 4
0
    def data(self):
        """Returns the data dictionary that represents the torus.

        Returns
        -------
        dict
            The torus data.

        Examples
        --------
        >>> from compas.geometry import Plane
        >>> from compas.geometry import Torus
        >>> torus = Torus(Plane.worldXY(), 5, 2)
        >>> sdict = {'plane': Plane.worldXY().data, 'radius_axis': 5., 'radius_pipe': 2.}
        >>> sdict == torus.data
        True

        """
        return {'plane': Plane.worldXY(),
                'radius_axis': self.radius_axis,
                'radius_pipe': self.radius_pipe}
Exemplo n.º 5
0
    def from_data(cls, data):
        """Construct a torus from its data representation.

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

        Returns
        -------
        Torus
            The constructed torus.

        Examples
        --------
        >>> from compas.geometry import Torus
        >>> data = {'plane': Plane.worldXY().data, 'radius_axis': 4., 'radius_pipe': 1.}
        >>> torus = Torus.from_data(data)

        """
        torus = cls(Plane.worldXY(), 1, 1)
        torus.data = data
        return torus
Exemplo n.º 6
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
Exemplo n.º 7
0
 def plane(self, plane):
     self.circle.plane = Plane(plane[0], plane[1])
Exemplo n.º 8
0
        >>> T = Transformation.from_frame(frame)
        >>> circle_transformed = cylinder.transformed(T)

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


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

if __name__ == "__main__":
    from compas.geometry import Transformation

    cylinder = Cylinder(Circle(Plane.worldXY(), 5), 7)
    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)
    cylinder.transform(T)
    print(cylinder)

    print(Plane.worldXY().data)
    data = {'circle': Circle(Plane.worldXY(), 5).data, 'height': 7.}
    cylinder = Cylinder.from_data(data)
    print(cylinder)

    import doctest
    doctest.testmod()
Exemplo n.º 9
0
 def plane(self, plane):
     self._plane = Plane(plane[0], plane[1])
Exemplo n.º 10
0
 def data(self, data):
     self.plane = Plane.from_data(data['plane'])
     self.radius_axis = data['radius_axis']
     self.radius_pipe = data['radius_pipe']
Exemplo n.º 11
0
        >>> torus = Torus(Plane.worldXY(), 5, 2)
        >>> frame = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
        >>> T = Transformation.from_frame(frame)
        >>> torus_transformed = torus.transformed(T)

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


if __name__ == '__main__':
    from compas.geometry import Frame
    from compas.geometry import Plane
    from compas.geometry import Transformation

    torus = Torus(Plane.worldXY(), 5, 2)
    frame = Frame([5, 0, 0], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
    T = Transformation.from_frame(frame)
    torus.transform(T)
    print(torus)

    torus = Torus(Plane.worldXY(), 5, 2)
    print(torus.data)
    print(torus)
    torus = Torus.from_data(torus.data)
    print(torus)

    import doctest
    doctest.testmod()
Exemplo n.º 12
0
 def data(self, data):
     self.plane = Plane.from_data(data['plane'])
     self.radius = data['radius']
Exemplo n.º 13
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()
Exemplo n.º 14
0
 def plane(self, plane):
     self._plane = Plane(*plane)
Exemplo n.º 15
0
 def data(self, data):
     self.plane = Plane.from_data(data['plane'])
     self.major = data['major']
     self.minor = data['minor']
Exemplo n.º 16
0
        """
        cone = self.copy()
        cone.transform(transformation)
        return cone


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

if __name__ == "__main__":
    from compas.geometry import Frame
    from compas.geometry import Transformation
    from compas.geometry import Circle

    cone = Cone(Circle(Plane.worldXY(), 5), 7)
    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)
    cone.transform(T)
    print(cone)

    print(Plane.worldXY().data)
    data = {'circle': Circle(Plane.worldXY(), 5).data, 'height': 7.}
    cone = Cone.from_data(data)
    print(cone)

    import doctest
    doctest.testmod()