예제 #1
0
    from math import radians

    from compas.geometry import Vector
    from compas.geometry import Line
    from compas.geometry import Rotation
    from compas.geometry import Translation
    from compas_plotters import Plotter2

    point = Point(0.0, 3.0, 0.0)
    vector = Vector(2.0, 0.0, 0.0)

    direction = vector.unitized()
    loa = Line(point, point + direction)

    R = Rotation.from_axis_and_angle(Vector(0.0, 0.0, 1.0), radians(3.6))
    T = Translation(direction.scaled(0.1))

    plotter = Plotter2()

    plotter.add(vector, point=point, draw_point=True)
    plotter.add(loa)
    plotter.draw(pause=1.0)

    for i in range(100):
        point.transform(T)
        vector.transform(R)
        plotter.redraw(pause=0.01)

    plotter.show()
예제 #2
0
"""Example: transform point and vector
"""
from compas.geometry import Point
from compas.geometry import Vector
from compas.geometry import Rotation

# create Rotation around point with axis and angle
point = Point(1.0, 0.0, 0.0)
axis, angle = [-0.248, -0.786, -0.566], 2.78
R = Rotation.from_axis_and_angle(axis, angle, point=point)

# apply Transformation to Point
p = Point(1, 1, 1)
p.transform(R)

# apply Transformation to Vector
v = Vector(1, 1, 1)
v.transform(R)

# should not be the same!
print(p)
print(v)