From a6a2c7816a859e39942addfee73987bb69d67492 Mon Sep 17 00:00:00 2001 From: lihinw <115400439+lihinw@users.noreply.github.com> Date: Tue, 30 May 2023 21:24:14 +0200 Subject: [PATCH] Create assignment_01.py --- .../lihin-weera/assignment_01.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lecture_02/assignment_01/lihin-weera/assignment_01.py diff --git a/lecture_02/assignment_01/lihin-weera/assignment_01.py b/lecture_02/assignment_01/lihin-weera/assignment_01.py new file mode 100644 index 0000000..8f4e99b --- /dev/null +++ b/lecture_02/assignment_01/lihin-weera/assignment_01.py @@ -0,0 +1,31 @@ +"""Assignment 01: Project box to xy-plane +""" +from compas.artists import Artist +from compas.datastructures import Mesh +from compas.geometry import Box +from compas.geometry import Frame +from compas.geometry import Plane +from compas.geometry import Projection + +# Define a Frame, which is not in the origin and a bit tilted to the world frame +frame = ([8, 5, 5], [10, 2, 5], [3, 7, 0]) + +# Create a Box with that frame +box = Box(frame, 3, 3, 3) + +# Create a Projection (can be orthogonal, parallel or perspective) +P = Projection.from_plane_and_direction(Plane.worldXY(), [2, 3, 4]) + +# Create a Mesh from the Box +mesh = Mesh.from_shape(box) + +# Apply the Projection onto the mesh +mesh_projected = mesh.transformed(P) + +# Create artists +artist1 = Artist(box) +artist2 = Artist(mesh_projected) + +# Draw and all to a list +a = [artist1.draw(),artist2.draw()] +a.extend(artist2.draw_edges(color="#00ff00")) \ No newline at end of file