詳解python polyscope庫(kù)的安裝和例程
安裝就可以在環(huán)境配置好的情況下使用pip安裝:
pip install polyscope
如果提示找不到庫(kù)文件,no moudle的話可以試著把安裝下來(lái)的polyscope文件夾放在和想要運(yùn)行的py文件的同一目錄下。而我們安裝下來(lái)的polyscope文件夾在哪里呢?它們應(yīng)該位于安裝目錄中的'Lib/site-packages'中,我的如下圖所示:
但是裝好之后我們運(yùn)行一個(gè)網(wǎng)上的例程:
import polyscope as ps# Initialize polyscopeps.init()### Register a point cloud# `my_points` is a Nx3 numpy arrayps.register_point_cloud('my points', my_points)### Register a mesh# `verts` is a Nx3 numpy array of vertex positions# `faces` is a Fx3 array of indices, or a nested listps.register_surface_mesh('my mesh', verts, faces, smooth_shade=True)# Add a scalar function and a vector function defined on the mesh# vertex_scalar is a length V numpy array of values# face_vectors is an Fx3 array of vectors per faceps.get_surface_mesh('my mesh').add_scalar_quantity('my_scalar', vertex_scalar, defined_on=’vertices’, cmap=’blues’)ps.get_surface_mesh('my mesh').add_vector_quantity('my_vector', face_vectors, defined_on=’faces’, color=(0.2, 0.5, 0.5))# View the point cloud and mesh we just registered in the 3D UIps.show()
還是有錯(cuò)誤,找不到polyscope_bindings,我的解決辦法是在這個(gè)目錄下面還應(yīng)該有一個(gè)這個(gè)文件:
把他的名字改成polyscope_bindings.pyd就可以解決,庫(kù)就可以跑通了。但是原例程因?yàn)闆]有給數(shù)組所有還有邏輯錯(cuò)誤,隨便給幾個(gè)就可以運(yùn)行了:
import polyscope as psimport numpy as np# Initialize polyscopeps.init()### Register a point cloud# `my_points` is a Nx3 numpy arraymy_points=np.array([[1,1,1],[1,2,3],[1,2,4],[2,5,3],[2,2,2]])ps.register_point_cloud('my points', my_points)### Register a mesh# `verts` is a Nx3 numpy array of vertex positions# `faces` is a Fx3 array of indices, or a nested listverts=np.array([[1,1,1],[1,2,3],[1,2,4],[2,5,3],[2,2,2]])faces=np.array([[1,1,1],[1,2,3],[1,2,4],[2,4,3],[2,2,2]])ps.register_surface_mesh('my mesh', verts, faces, smooth_shade=True)# Add a scalar function and a vector function defined on the mesh# vertex_scalar is a length V numpy array of values# face_vectors is an Fx3 array of vectors per facevertex_scalar = np.array([1,2,3,4,5])face_vectors=np.array([[1,1,1],[1,2,3],[1,2,4],[2,5,3],[2,2,2]])ps.get_surface_mesh('my mesh').add_scalar_quantity('my_scalar', vertex_scalar, defined_on=’vertices’, cmap=’blues’)ps.get_surface_mesh('my mesh').add_vector_quantity('my_vector', face_vectors, defined_on=’faces’, color=(0.2, 0.5, 0.5))# View the point cloud and mesh we just registered in the 3D UIps.show()
這就可以成功使用了
到此這篇關(guān)于python polyscope庫(kù)的安裝和例程的文章就介紹到這了,更多相關(guān)python polyscope庫(kù)內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. IntelliJ IDEA安裝插件的方法步驟2. ASP.NET MVC使用typeahead.js實(shí)現(xiàn)輸入智能提示功能3. ASP編碼和解碼函數(shù)詳解4. 深入理解Android熱修復(fù)技術(shù)原理之資源熱修復(fù)技術(shù)5. 詳解Python類和對(duì)象內(nèi)容6. 淺談從Java中的棧和堆,進(jìn)而衍生到值傳遞7. Vue過(guò)濾器,生命周期函數(shù)和vue-resource簡(jiǎn)單介紹8. vue中echarts引入中國(guó)地圖的案例9. 從vue-router看前端路由的兩種實(shí)現(xiàn)10. Android Manifest中meta-data擴(kuò)展元素?cái)?shù)據(jù)的配置與獲取方式
