Ejemplo n.º 1
0
def vectors_from_angles(angles, base_vector):

    vectors = {}

    for fkey, angle in angles.items():
        rot_pts = rotate_points([base_vector], angle)
        vectors[fkey] = vector_from_angle(angle, base_vector)

    return vectors
Ejemplo n.º 2
0
 def get_distance(self, point):
     """
     single point distance function
     """
     plane = Plane(self.frame.point, self.frame.normal)
     plndst = distance_point_plane_signed(point, plane)
     pr = rotate_points([point], plndst / 10, self.frame.normal,
                        self.frame.point)
     d = self.obj.get_distance(pr[0])
     return d
Ejemplo n.º 3
0
    def rotate_mesh(mesh):
        origin = mesh.centroid()
        axis = [1, 0, 0]

        new_points = rotate_points(
            [mesh.vertex_coordinates(vkey) for vkey in mesh.vertices()],
            -pi / 4, axis, origin)
        for vkey, (x, y, z) in zip(mesh.vertices(), new_points):
            mesh.vertex[vkey]['x'] = x
            mesh.vertex[vkey]['y'] = y
            mesh.vertex[vkey]['z'] = z
def rotate_mesh(mesh, angle):
    centroid = mesh_centroid(mesh)
    normal = mesh_normal(mesh)
    for vkey in mesh.vertices():
        xyz = rotate_points([mesh.vertex_coordinates(vkey)], normal, angle,
                            centroid)
        x, y, z = xyz[0]
        attr = mesh.vertex[vkey]
        attr['x'] = x
        attr['y'] = y
        attr['z'] = z
Ejemplo n.º 5
0
def rotate_dual(force_net, ANG):
    """
    rotates the force_net coordinates 90 deg counterclockwise
    """
    # save the rotated verteces in ver_coor_90_dic    
    ver_coor_90_dic={}
    AX=[0.0, 0.0, 1.0]  # normal to the plane of rotation
    ORG=[0.0, 0.0, 0.0]
    for key in force_net.node:
        coor=force_net.node_coordinates(key)
        pt=rotate_points([coor], ANG, AX, ORG) 
        ver_coor_90_dic[key]=np.round_(pt[0], 3).tolist()            
    # make new rotated dual network 
    force_90_net=Network()
    for key, coor in ver_coor_90_dic.items():
        force_90_net.add_node(key, {'x': coor[0], 'y': coor[1], 'z': coor[2]})       
    for edg in force_net.edges():
        force_90_net.add_edge(edg[0], edg[1])    

    return force_90_net
Ejemplo n.º 6
0
def test_rotate_points():
    assert allclose(rotate_points([[0, 1, 2]], 1),
                    [[-0.8414709848078965, 0.5403023058681398, 2.0]])
from math import radians

import compas
import compas_rhino

from compas.geometry import rotate_points

from compas.datastructures import Mesh

from compas_rhino.artists import MeshArtist

# make a mesh from the Stanford bunny PLY file

mesh = Mesh.from_ply(compas.get_bunny())

# rotate the bunny to align it with the Z axis
# display the results in Rhino

points = [mesh.vertex_coordinates(key) for key in mesh.vertices()]
points = rotate_points(points, radians(90), [1.0, 0.0, 0.0])

for index, (key, attr) in enumerate(mesh.vertices(True)):
    attr['x'] = points[index][0]
    attr['y'] = points[index][1]
    attr['z'] = points[index][2]

artist = MeshArtist(mesh)
artist.draw_faces(join_faces=True)
artist.redraw()
Ejemplo n.º 8
0
def vector_from_angle(angle, base_vector):

    rot_pts = rotate_points([base_vector], angle)
    return rot_pts[0]