forked from gramaziokohler/workshop_swinburne_2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
106_examples_transformation.py
34 lines (28 loc) · 1022 Bytes
/
106_examples_transformation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Transformation examples
"""
from compas.geometry import Rotation
from compas.geometry import Translation
from compas.geometry import Scale
from compas.geometry import Reflection
from compas.geometry import Projection
from compas.geometry import Shear
axis, angle = [0.2, 0.4, 0.1], 0.3
R = Rotation.from_axis_and_angle(axis, angle)
print("Rotation:\n", R)
translation_vector = [5, 3, 1]
T = Translation.from_vector(translation_vector)
print("Translation:\n", T)
scale_factors = [0.1, 0.3, 0.4]
S = Scale.from_factors(scale_factors)
print("Scale:\n", S)
point, normal = [0.3, 0.2, 1], [0.3, 0.1, 1]
R = Reflection.from_plane((point, normal))
print("Reflection:\n", R)
point, normal = [0, 0, 0], [0, 0, 1]
perspective = [1, 1, 0]
P = Projection.from_plane_and_point((point, normal), perspective)
print("Perspective projection:\n", R)
angle, direction = 0.1, [0.1, 0.2, 0.3]
point, normal = [4, 3, 1], [-0.11, 0.31, -0.17]
S = Shear.from_angle_direction_plane(angle, direction, (point, normal))
print("Shear:\n", S)