def create_transformation_matrix(coors): r""" Create a transposed coordinate transformation matrix, that transforms 3D coordinates of quadrilateral cell vertices so that the transformed vertices of a plane cell are in the :math:`x-y` plane. The rotation is performed w.r.t. the centres of quadrilaterals. Parameters ---------- coors : array The coordinates of cell vertices, shape `(n_el, 4, 3)`. Returns ------- mtx_t : array The transposed transformation matrix :math:`T`, i.e. :math:`X_{inplane} = T^T X_{3D}`. Notes ----- :math:`T = [t_1, t_2, n]`, where :math:`t_1`, :math:`t_2`, are unit in-plane (column) vectors and :math:`n` is the unit normal vector, all mutually orthonormal. """ # Local coordinate system. t1 = coors[:, 1, :] + coors[:, 2, :] - coors[:, 0, :] - coors[:, 3, :] t2 = coors[:, 2, :] + coors[:, 3, :] - coors[:, 0, :] - coors[:, 1, :] n = nm.cross(t1, t2) t2 = nm.cross(n, t1) t1 = t1 / norm(t1)[:, None] t2 = t2 / norm(t2)[:, None] n = n / norm(n)[:, None] # Coordinate transformation matrix (transposed!). mtx_t = nm.concatenate((t1[:, :, None], t2[:, :, None], n[:, :, None]), axis=2) return mtx_t
def create_transformation_matrix(coors): """ Create a transposed coordinate transformation matrix, that transforms 3D coordinates of element face nodes so that the transformed nodes are in the `x-y` plane. The rotation is performed w.r.t. the first node of each face. Parameters ---------- coors : array The coordinates of element nodes, shape `(n_el, n_ep, dim)`. Returns ------- mtx_t : array The transposed transformation matrix :math:`T`, i.e. :math:`X_{inplane} = T^T X_{3D}`. Notes ----- :math:`T = [t_1, t_2, n]`, where :math:`t_1`, :math:`t_2`, are unit in-plane (column) vectors and :math:`n` is the unit normal vector, all mutually orthonormal. """ # Local coordinate system. t1 = coors[:, 1, :] - coors[:, 0, :] t2 = coors[:, -1, :] - coors[:, 0, :] n = nm.cross(t1, t2) t2 = nm.cross(n, t1) t1 = t1 / norm(t1)[:, None] t2 = t2 / norm(t2)[:, None] n = n / norm(n)[:, None] # Coordinate transformation matrix (transposed!). mtx_t = nm.concatenate((t1[:, :, None], t2[:, :, None], n[:, :, None]), axis=2) return mtx_t