2017-10-21 9 views
0

MayaviモジュールのPython用が初めてで、私にとっては何か不明です。私は現在、triangle_mesh関数を使ってモデルを表示することができました。問題は、モデルを5倍大きく表示するようにモデルをスケールアップしたいのですが、どのようにすればいいのか理解できません。私は頂点配列Vを更新しようとしましたが、すべてが同じように見えます。コードは以下の通りです。どうにかして、頂点を含むV配列を変換する必要があると思いますが、モデルを5倍大きく表示できるように変換する方法を理解できません。Mayaviで3Dモデルをスケールアップする方法

import math 
import numpy as np 
import mayavi.mlab as mlab 
import pickle 

    # The following three lines will load the "pickled" arrays V and F from the 
    # pickle file dino.pkl. V represents the vertices of the model as Nx3 matrix, 
    # while N is the number of vertices the model consists of. F represent the 
    # faces (here triangles of the model). F is also a Nx3 matrix, while here N 
    # represents the number of the faces the model. 
    fid = open('dino.pkl', 'rb') 
    (V, F) = pickle.load(fid) 
    fid.close() 

    # a small wrapper function around mlab's triangular_mesh 
    # input are the face-vertex indices inside an (M x 3) array F 
    # and the vertices in a (N x 3) array V 
    def trimesh(F, V, new_figure=True): 
     if new_figure: 
      mlab.figure() 
      mlab.triangular_mesh(V[:,0], V[:,1] , V[:,2] , F) 
      mlab.show() 


    # small helper function that is used to visualize the coordinate axes 
    def draw_axes(): 
     mlab.points3d(1, 0, 0, 1, scale_factor=0.1, color=(1, 0, 0)) 
     mlab.points3d(0, 1, 0, 1, scale_factor=0.1, color=(0, 1, 0)) 
     mlab.points3d(0, 0, 1, 1, scale_factor=0.1, color=(0, 0, 1)) 
     mlab.plot3d([0, 1], [0, 0], [0, 0]) 
     mlab.plot3d([0, 0], [0, 1], [0, 0]) 
     mlab.plot3d([0, 0], [0, 0], [0, 1]) 


    # show dino triangle mesh 
    draw_axes() 
    trimesh(F, V) 

答えて

0

IはMayaviに慣れていないんだけど、docsによれば、scale_factor引数は各点に対して引かグリフのサイズに影響を与えます。プロット全体のサイズを変更する場合は、代わりにextentを指定します。

関連する問題