Examples
Planes and frames
Place geometry with frames and show it in COMPAS Viewer
A plane is a point and a normal. A frame adds two axes, which makes it a full local coordinate system. This example builds a box on the world XY frame and moves it onto a tilted frame. It needs compas_viewer; see Making a box to install it.
The script
planes_and_frames.py
from compas.geometry import Box, Frame, Plane, Transformation
from compas_viewer import Viewer
plane = Plane([0, 0, 0], [0, 0, 1])
source = Frame.from_plane(plane)
target = Frame([4, 2, 1], [1, 1, 0], [-1, 1, 1])
box = Box(1, 1, 2, frame=source)
X = Transformation.from_frame_to_frame(source, target)
moved = box.transformed(X)
viewer = Viewer()
for obj in (source, target, box.to_mesh(), moved.to_mesh()):
viewer.scene.add(obj)
viewer.show()
Frame(point, xaxis, yaxis) normalizes the axes and makes them perpendicular, so they don't need to be unit length. from_frame_to_frame maps one frame onto another; anything placed on the source frame lands on the target the same way.