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
>>> 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()
def data(self, data): self.circle = Circle.from_data(data['circle']) self.height = data['height']
""" 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()