コード例 #1
0
    def test_cylindrical_rotation_matrix(self):
        """tests cylindrical_rotation_matrix"""
        theta = [0., 0.]
        coords = cylindrical_rotation_matrix(theta, dtype='float64')

        theta = np.radians([0., 45., 90.])
        coords = cylindrical_rotation_matrix(theta, dtype='float64')
コード例 #2
0
 def test_dot_n33_n33(self):
     """tests dot_n33_n33"""
     A = np.array([
         [
             [1., 0., 0.],
             [0., 1., 0.],
             [0., 0., 1.],
         ],
         [
             [1., 0., 0.],
             [0., 1., 0.],
             [0., 0., 1.],
         ],
         [
             [1., 0., 0.],
             [0., 1., 0.],
             [0., 0., 1.],
         ],
     ])
     theta = np.radians([0., 45., 90])
     B = cylindrical_rotation_matrix(theta, dtype='float64')
     C = dot_n33_n33(A, B)
コード例 #3
0
ファイル: transforms.py プロジェクト: zhenhaochu/pyNastran
def _transform_cylindrical_displacement(inode, data, coord, xyz_cid0,
                                        cid_transform, is_global_cid):
    """helper method for transform_displacement_to_global"""
    xyzi = xyz_cid0[inode, :]
    rtz_cid = coord.xyz_to_coord_array(xyzi)

    #print('rtz_cid:')
    #print(rtz_cid)
    thetad = rtz_cid[:, 1]
    thetar = np.radians(thetad)
    #print('thetad[cid=%s] = %s' % (coord.cid, thetad))
    #print('thetar = ', thetar)
    #self.log.debug('thetad = %s' % list(thetad))

    #np.set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, suppress=True,
    #nanstr=None, infstr=None, formatter=None, sign=None, floatmode=None)
    xforms = cylindrical_rotation_matrix(thetar, dtype='float64')
    #print('xforms.shape = %s' % str(xforms.shape))

    for itime in range(data.shape[0]):
        translation = data[itime, inode, :3]
        rotation = data[itime, inode, 3:]
        #theta_max1 = translation[:, 1].max()
        #theta_max2 = rotation[:, 1].max()
        #print('theta_max = ', max(theta_max1, theta_max2))

        if is_global_cid:
            translation2 = dot_n33_n3(xforms, translation)
            rotation2 = dot_n33_n3(xforms, rotation)
        else:
            #print('cid_transform[cid=%s]:\n%s' % (coord.cid, cid_transform))
            #print('xforms:\n%s' % (xforms))
            #xforms2 = dot_33_n33(xforms, cid_transform)  # wrong shape
            #xforms2a = dot_33_n33(cid_transform, xforms)
            #xforms2b = dot_n33_33(xforms, cid_transform)
            #xforms2b = xforms
            # triple products
            #xforms2c = dot_33_n33(cid_transform.T, dot_n33_33(xforms, cid_transform))
            #xforms2d = dot_33_n33(cid_transform, dot_n33_33(xforms, cid_transform.T))

            #print('xform A:\n%s'  % xforms2a)
            #print('xform B:\n%s'  % xforms2b)
            #translation2 = dot_n33_n3(xforms2a, translation)
            #xforms2 = xforms2b
            if 1:
                xforms2b = dot_n33_33(xforms, cid_transform)
                translation2 = dot_n33_n3(xforms2b, translation)
                rotation2 = dot_n33_n3(xforms2b, rotation)
            elif 0:  ## pragma: no cover
                xforms2b = dot_n33_33(xforms, cid_transform)
                translation2a = dot_n33_n3(xforms2b, translation)
                rotation2a = dot_n33_n3(xforms2b, rotation)
                print('translation2a.shape =', translation2a.shape)
                assert translation.shape == translation2a.shape

                translation2 = translation2a @ cid_transform
                rotation2 = rotation2a @ cid_transform

            elif 0:  ## pragma: no cover
                # bad shape
                translation2a = dot_n33_n3(xforms, translation)
                rotation2a = dot_n33_n3(xforms, rotation)
                print('translation2a.shape =', translation2a.shape)
                assert translation.shape == translation2a.shape

                translation2 = cid_transform @ translation2a @ cid_transform
                rotation2 = cid_transform @ rotation2a @ cid_transform
            else:  ## pragma: no cover
                raise NotImplementedError('pick an option...')
        #print('translation.shape', translation.shape)
        #print('translation2.shape', translation2.shape)
        data[itime, inode, :3] = translation2
        data[itime, inode, 3:] = rotation2