Exemplo n.º 1
0
 def __init__(self,
              pt1,
              pt2,
              thickness,
              dist_from_pt1,
              height,
              vertical_vector,
              polyline2d,
              close=False):
     self.close = None
     epsilon = 0.01
     wall = Wall(pt1, pt2, thickness, vertical_vector)
     bottom_center = Point(
         [pt1[i] + dist_from_pt1 * wall.matrix[2][i] for i in range(3)])
     center = Point([
         bottom_center[i] + height * wall.matrix[1][i] - 0.5 *
         (thickness + epsilon) * wall.matrix[0][i] for i in range(3)
     ])
     frame = Frame([center, wall.matrix])
     self.ex = extrude_polyline2d(polyline2d, frame, thickness + epsilon)
     if close:
         center = Point([
             bottom_center[i] + height * wall.matrix[1][i] - 0.5 *
             (0.25 * thickness) * wall.matrix[0][i] for i in range(3)
         ])
         frame = Frame([center, wall.matrix])
         self.close = extrude_polyline2d(polyline2d, frame, 0.5 * thickness)
Exemplo n.º 2
0
    def parameter_frame(self, s, mode=Vector([0., 0., 1.])):
        basis = []
        t = self.parameter_point(s)
        orig = t
        if (type(mode) == Vector):
            vec = mode.unit()
        elif mode == 'Xnat':
            vec = (1., 0., 0.)
        elif mode == 'Ynat':
            vec = (0., 1., 0.)
        elif mode == 'Znat':
            vec = (0., 0., 1.)

        tph = self.parameter_point(s + 0.001)
        xp = Vector(
            [float(tph[0] - t[0]),
             float(tph[1] - t[1]),
             float(tph[2] - t[2])])
        T = xp.unit()
        basis.append(T)
        B = cross(vec, T)
        basis.append(B)
        N = cross(T, B)
        basis.append(N)

        matrix = [None, None, None]
        for i in range(3):
            matrix[i] = [float(basis[i][j]) for j in range(3)]
        return Frame((orig, matrix))
Exemplo n.º 3
0
 def __init__(self, pt1, pt2, thickness, vertical_vector):
     super(Wall, self).__init__([pt1, pt2])
     vert = vertical_vector.unit()
     wall_direction = Vector([pt2[i] - pt1[i] for i in range(3)]).unit()
     normal_direction = cross(wall_direction, vertical_vector).unit()
     self.matrix = [[normal_direction[i] for i in range(3)],
                    [vert[i] for i in range(3)],
                    [wall_direction[i] for i in range(3)]]
     self.thickness = thickness
     frame = Frame([pt1, self.matrix])
Exemplo n.º 4
0
 def __init__(self, pt1, pt2, wall_thickness, box_thickness, box_offset,
              dist_from_pt1, height, vertical_vector, polyline2d):
     epsilon = 0.01
     wall = Wall(pt1, pt2, wall_thickness, vertical_vector)
     bottom_center = Point(
         [pt1[i] + dist_from_pt1 * wall.matrix[2][i] for i in range(3)])
     center = Point([
         bottom_center[i] + height * wall.matrix[1][i] +
         (0.5 * wall_thickness + box_offset) * wall.matrix[0][i]
         for i in range(3)
     ])
     frame = Frame([center, wall.matrix])
     self.ex = extrude_polyline2d(polyline2d, frame, box_thickness)
Exemplo n.º 5
0
def parameter_frame(tck, s, mode='frenet'):
    basis = []
    t = interpolate.splev(s, tck, der=0)
    orig = Point([t[0], t[1], t[2]])
    if mode == 'frenet':
        t = interpolate.splev(s, tck, der=1)
        xp = Vector([float(t[0]), float(t[1]), float(t[2])])
        t = interpolate.splev(s, tck, der=2)
        xpp = Vector([float(t[0]), float(t[1]), float(t[2])])
        T = xp.unit()
        basis.append(T.unit())
        B = cross(xp, xpp)
        basis.append(B.unit())
        N = cross(B, T)
        basis.append(N.unit())

    if mode == 'Xnat':
        t = interpolate.splev(s, tck, der=1)
        xp = Vector([float(t[0]), float(t[1]), float(t[2])])
        T = xp.unit()
        basis.append(T)
        B = cross((1., 0., 0.), T)
        basis.append(B)
        N = cross(T, B)
        basis.append(N)

    if mode == 'Ynat':
        t = interpolate.splev(s, tck, der=1)
        xp = Vector([float(t[0]), float(t[1]), float(t[2])])
        T = xp.unit()
        basis.append(T)
        B = cross((0., 1., 0.), T)
        basis.append(B)
        N = cross(T, B)
        basis.append(N)

    if mode == 'Znat':
        t = interpolate.splev(s, tck, der=1)
        xp = Vector([float(t[0]), float(t[1]), float(t[2])])
        T = xp.unit()
        basis.append(T)
        B = cross((0., 0., 1.), T)
        basis.append(B)
        N = cross(T, B)
        basis.append(N)

    matrix = np.zeros((3, 3), dtype=float)
    for i in range(3):
        matrix[i] = basis[i]
    return Frame((orig, matrix))
Exemplo n.º 6
0
    def parameter_frame(self, s, mode='frenet'):
        basis = []
        t = interpolate.splev(s, self.tck, der=0)
        orig = Point([float(t[i]) for i in range(3)])
        if mode == 'frenet':
            t = interpolate.splev(s, self.tck, der=1)
            xp = Vector([float(t[0]), float(t[1]), float(t[2])])
            t = interpolate.splev(s, tck, der=2)
            xpp = Vector([float(t[0]), float(t[1]), float(t[2])])
            T = xp.unit()
            basis.append(T.unit())
            B = cross(xp, xpp)
            basis.append(B.unit())
            N = cross(B, T)
            basis.append(N.unit())
        else:
            if (type(mode) == Vector):
                vec = mode.unit()
            elif mode == 'Xnat':
                vec = (1., 0., 0.)
            elif mode == 'Ynat':
                vec = (0., 1., 0.)
            elif mode == 'Znat':
                vec = (0., 0., 1.)
            t = interpolate.splev(s, self.tck, der=1)
            xp = Vector([float(t[0]), float(t[1]), float(t[2])])
            T = xp.unit()
            basis.append(T)
            B = cross(vec, T)
            basis.append(B)
            N = cross(T, B)
            basis.append(N)

            matrix = [None, None, None]
            for i in range(3):
                matrix[i] = [float(basis[i][j]) for j in range(3)]
            return Frame((orig, matrix))
Exemplo n.º 7
0
ndisc = 20
fa = spline.frame_array(mode=Vector([0., 0., 1.]), n=ndisc)

for f in fa:
    pp = pol.to_frame(f, scale=0.2)
    pp.pop_to_geom(geom)

cpol = spline.control_polyline
pol_gen = spline.discretize(ndisc)

sym = spline.symmetrize()

fasym = sym.frame_array(mode=Vector([0., 0., 1.]), n=ndisc)
sym_pol_gen = sym.discretize(ndisc)
for i, f in enumerate(fa):
    bas = f[1]
    new_bas = [[-bas[0][0], -bas[0][1], -bas[0][1]],
               [bas[1][0], bas[1][1], bas[1][1]],
               [bas[2][0], bas[2][1], bas[2][1]]]

    fmirror = Frame([fasym[i][0], new_bas])
    pp = pol.to_frame(fmirror, scale=0.2)
    pp.pop_to_geom(geom)

cpol.pop_to_geom(geom)
pol_gen.pop_to_geom(geom)
sym.control_polyline.pop_to_geom(geom)
sym_pol_gen.pop_to_geom(geom)

write_geo('toto', geom)
Exemplo n.º 8
0
data = {
    'points': [
        Point([-5., 2.5, 0.]),
        Point([5., 2.5, 0.]),
        Point([5., -2.5, 0.]),
        Point([0., 2.5, 0.]),
        Point([0., -2.5, 0.]),
        Point([-5., -2.5, 0.])
    ],
    'walls': [[0, 3], [3, 1], [1, 2], [2, 4], [4, 5], [5, 0], [3, 4]]
}
thick = 0.15

total_height = 3.

floor_frame = Frame([[0., 0., 0.], [1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
ceiling_frame = Frame([[0., 0., total_height], [1., 0., 0.], [0., 1., 0.],
                       [0., 0., 1.]])

horiz = Polyline2D([[-30., -30.], [30., -30.], [30., 30.], [-30., 30.]],
                   closed=True)

floor = extrude_polyline2d(horiz, floor_frame, -0.5)
ceiling = extrude_polyline2d(horiz, ceiling_frame, 0.5)

polylines = []
all_tree_nodes = []
thick = 0.15
for ipoint, point in enumerate(data['points']):
    sector = [point]
    for iwall, wall in enumerate(data['walls']):