def _3d_to_2d(fig, xyz):
 from mayavi.core.scene import Scene
 if (not isinstance(fig, Scene)):
  raise TypeError(('fig must be an instance of Scene, found type %s' % type(fig)))
 xyz = np.column_stack([xyz, np.ones(xyz.shape[0])])
 comb_trans_mat = _get_world_to_view_matrix(fig.scene)
 view_coords = np.dot(comb_trans_mat, xyz.T).T
 norm_view_coords = (view_coords / view_coords[:, 3].reshape((-1), 1))
 view_to_disp_mat = _get_view_to_display_matrix(fig.scene)
 xy = np.dot(view_to_disp_mat, norm_view_coords.T).T
 xy = xy[:, :2]
 return xy

def _3d_to_2d ( fig , xyz ) : from mayavi . core . scene import Scene if ( not isinstance ( fig , Scene ) ) : raise TypeError ( ( 'fig must be an instance of Scene, found type %s' % type ( fig ) ) ) xyz = np . column_stack ( [ xyz , np . ones ( xyz . shape [ 0 ] ) ] ) comb_trans_mat = _get_world_to_view_matrix ( fig . scene ) view_coords = np . dot ( comb_trans_mat , xyz . T ) . T norm_view_coords = ( view_coords / view_coords [ : , 3 ] . reshape ( ( - 1 ) , 1 ) ) view_to_disp_mat = _get_view_to_display_matrix ( fig . scene ) xy = np . dot ( view_to_disp_mat , norm_view_coords . T ) . T xy = xy [ : , : 2 ] return xy
convert 3d points to a 2d perspective using a mayavi scene .