Example #1
0
        'arrow': 'end'
    }, {
        'start': origin,
        'end': zaxis,
        'color': (0, 0, 255),
        'arrow': 'end'
    }]
    compas_rhino.draw_points(points, layer=layer, clear=False)
    compas_rhino.draw_lines(lines, layer=layer, clear=False)


# ==============================================================================
# Algorithm
# ==============================================================================

cloud1 = pointcloud(30, (0, 10), (0, 3), (0, 5))
bbox1 = bounding_box(cloud1)

Rz = Rotation.from_axis_and_angle([0.0, 0.0, 1.0], radians(60))
Ry = Rotation.from_axis_and_angle([0.0, 1.0, 0.0], radians(20))
Rx = Rotation.from_axis_and_angle([1.0, 0.0, 0.0], radians(10))

T = Translation([2.0, 5.0, 8.0])

R = T * Rz * Ry * Rx

cloud2 = transform_points(cloud1, R)
bbox2 = transform_points(bbox1, R)

mean, vectors, values = numerical.pca_numpy(cloud2)
Example #2
0
import random
from math import radians

from compas.geometry import pointcloud
from compas.geometry import Point
from compas.geometry import Vector
from compas.geometry import Rotation
from compas.geometry import Translation
from compas.geometry import icp_numpy
from compas_plotters import Plotter2

R = Rotation.from_axis_and_angle(Vector.Zaxis(), radians(30))

source = [Point(*xyz) for xyz in pointcloud(30, (0, 10), (0, 5), (0, 3))]
observations = Point.transformed_collection(source, R)

noise = []
for i in range(5):
    point = random.choice(observations)
    T = Translation([random.random(), random.random(), random.random()])
    noise.append(point.transformed(T))

outliers = [Point(*xyz) for xyz in pointcloud(3, (10, 15), (0, 5), (0, 3))]
Point.transform_collection(outliers, R)

target = observations + noise + outliers

# A, X = icp_numpy(source, target)
# source_new = [Point(*point) for point in A]

plotter = Plotter2()