def offset_polygon_xy(points, dist, planarize=False):
    if len(points) < 3:
        return None
    frame = Frame.from_plane(
        Plane.from_three_points(points[0], points[1], points[2]))
    xform = Transformation.from_frame_to_frame(frame, Frame.worldXY())
    if planarize:
        points = [point_on_plane(point, frame) for point in points]
    points = transform_points(points, xform)
    points = offset_polygon(points, dist)
    points = transform_points(points, xform.inverse())
    return points
Exemple #2
0
def tet_from_points(tet_end_points):
    assert len(tet_end_points) == 4, 'input points must be four!'
    ids = frozenset([0,1,2,3])
    faces = []
    if is_coplanar(tet_end_points):
        return None, None
    for face in combinations(ids, 3):
        left_id, = ids - set(face)
        if is_point_infront_plane(tet_end_points[left_id], Plane.from_three_points(*[tet_end_points[i] for i in face])):
            face = [face[0], face[2], face[1]]
        faces.append(list(face) + [left_id])
    return tet_end_points, faces
from compas.geometry import Frame
from compas.geometry import Plane
from compas.geometry import Vector

a = Vector(1, 0, 0)
b = Vector.from_start_end([1, 0, 0], [2, 0, 0])
assert a == b

a = Plane([0, 0, 0], [0, 0, 1])
b = Plane.from_three_points([0, 0, 0], [1, 0, 0], [0, 1, 0])
assert a == b

a = Frame([0, 0, 0], [3, 0, 0], [0, 2, 0])
b = Frame.from_points([0, 0, 0], [5, 0, 0], [1, 2, 0])
assert a == b