Ejemplo n.º 1
0
 def transform_ffd1(R):
     O, D, Pw = R._O, R._D, R._Pw
     z0 = O.xyz[2]
     sf = (R.xyz[2] - z0) / D
     if not np.allclose(sf, 1.0):
         x = R.xyz[0]
         scale(Pw, sf, [x, 0, z0], [0, 0, 1])
     R._D = R.xyz[2] - z0
Ejemplo n.º 2
0
 def transform_ffd0(O):
     R, D, Pw = O._R, O._D, O._Pw
     sf = O.xyz[1] / D
     if not np.allclose(sf, 1.0):
         scale(Pw, sf, L=[0, 1, 0])
     dz = O.xyz[2] - Pw[0, 0, 2]
     if not np.allclose(dz, 0.0):
         Om = [r._xyzw for r in R] + [Pw]
         for o in Om:
             translate(o, [0, 0, dz])
     O._D = O.xyz[1]
Ejemplo n.º 3
0
 def transform_ffd(R):
     O, D, S, Pw = R._O, R._D, R._S, R._Pw
     D_new = distance(O, R.xyz)
     sf = D_new / D
     if np.allclose(sf, 1.0):
         return
     scale(Pw, sf, R.line[0], R.line[1])
     R._D = D_new
     if S and not np.allclose(S.xyz[2], R.xyz[2]):
         args = S.line[0], S.line[1], R.xyz, [0, 1, 0]
         xyz = intersect_3D_lines(*args)
         S._xyzw[1:3] = xyz[1:3]
         S.transform_ffd(S)
Ejemplo n.º 4
0
    def _setup(self):
        def transform_ffd(R):
            O, D, S, Pw = R._O, R._D, R._S, R._Pw
            D_new = distance(O, R.xyz)
            sf = D_new / D
            if np.allclose(sf, 1.0):
                return
            scale(Pw, sf, R.line[0], R.line[1])
            R._D = D_new
            if S and not np.allclose(S.xyz[2], R.xyz[2]):
                args = S.line[0], S.line[1], R.xyz, [0, 1, 0]
                xyz = intersect_3D_lines(*args)
                S._xyzw[1:3] = xyz[1:3]
                S.transform_ffd(S)

        super(FairingMolder, self)._setup()
        Ps = []
        for i in xrange(self.cobj.n[0] + 1):
            Pw = self.cobj.Pw[i, :, 1]

            R = Pw[-1].copy()
            O = Pw[0, :3]
            L = Pw[-1, :3] - O
            scale(R, 1.3, O, L)  # knob
            R = Point(*R)
            Ps.append(R)

            R._O = O
            R._D = distance(O, R.xyz)
            R._S = None
            R._Pw = Pw
            R.line = O, L

            R.transform_ffd = transform_ffd
            R.ffd = self

        Ps[0]._S = Ps[1]
        Ps[1]._S = Ps[0]
        Ps[-2]._S = Ps[-1]
        Ps[-1]._S = Ps[-2]

        self.pilot_points = Ps
        self.glued = Ps + [self]
Ejemplo n.º 5
0
    def _setup(self):
        def transform_ffd0(O):
            R, D, Pw = O._R, O._D, O._Pw
            sf = O.xyz[1] / D
            if not np.allclose(sf, 1.0):
                scale(Pw, sf, L=[0, 1, 0])
            dz = O.xyz[2] - Pw[0, 0, 2]
            if not np.allclose(dz, 0.0):
                Om = [r._xyzw for r in R] + [Pw]
                for o in Om:
                    translate(o, [0, 0, dz])
            O._D = O.xyz[1]

        def transform_ffd1(R):
            O, D, Pw = R._O, R._D, R._Pw
            z0 = O.xyz[2]
            sf = (R.xyz[2] - z0) / D
            if not np.allclose(sf, 1.0):
                x = R.xyz[0]
                scale(Pw, sf, [x, 0, z0], [0, 0, 1])
            R._D = R.xyz[2] - z0

        super(FuselageMolder, self)._setup()
        n, dummy, l = self.cobj.n
        Ps = []
        for k in xrange(l + 1):
            Pw = self.cobj.Pw[:, :, k]

            O = Pw[n / 2, 0, :3]
            R = Pw[n / 2, -1].copy()
            R[2] = O[2]
            L = R[:3] - O
            scale(R, 1.3, O, L)  # knob
            R = Point(*R)
            Ps.append(R)
            R._D = R.xyz[1]
            R._Pw = Pw
            R.plane = O, [1, 0, 0]
            R.transform_ffd = transform_ffd0

            O = Pw[-1, 0, :3]
            R = Pw[-1, -1].copy()
            L = R[:3] - O
            scale(R, 1.3, O, L)  # knob
            R = Point(*R)
            Ps.append(R)
            R._D = R.xyz[2] - O[2]
            R._Pw = Pw[n / 2:]
            R.line = O, [0, 0, 1]
            R.transform_ffd = transform_ffd1

            O = Pw[0, 0, :3]
            R = Pw[0, -1].copy()
            L = R[:3] - O
            scale(R, 1.3, O, L)  # knob
            R = Point(*R)
            Ps.append(R)
            R._D = R.xyz[2] - O[2]
            R._Pw = Pw[:n / 2]
            R.line = O, [0, 0, 1]
            R.transform_ffd = transform_ffd1

            O, R0, R1 = Ps[-3:]
            O._R = (R0, R1)
            R0._O = O
            R1._O = O

        for p in Ps:
            p.ffd = self

        self.pilot_points = Ps
        self.glued = Ps + [self]