詳解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 polyscope ps.init() ### Register a point cloud # `my_points` is a Nx3 numpy array 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 list 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 face 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 UI ps.show()
還是有錯(cuò)誤,找不到polyscope_bindings,我的解決辦法是在這個(gè)目錄下面還應(yīng)該有一個(gè)這個(gè)文件:
把他的名字改成polyscope_bindings.pyd就可以解決,庫(kù)就可以跑通了。但是原例程因?yàn)闆](méi)有給數(shù)組所有還有邏輯錯(cuò)誤,隨便給幾個(gè)就可以運(yùn)行了:
import polyscope as ps import numpy as np # Initialize polyscope ps.init() ### Register a point cloud # `my_points` is a Nx3 numpy array my_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 list verts=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 face vertex_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 UI ps.show()
這就可以成功使用了
到此這篇關(guān)于python polyscope庫(kù)的安裝和例程的文章就介紹到這了,更多相關(guān)python polyscope庫(kù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python報(bào)錯(cuò):TypeError:?‘xxx‘?object?is?not?subscriptable解決
這篇文章主要給大家介紹了關(guān)于Python報(bào)錯(cuò):TypeError:?‘xxx‘?object?is?not?subscriptable的解決辦法,TypeError是Python中的一種錯(cuò)誤,表示操作或函數(shù)應(yīng)用于不合適類型的對(duì)象時(shí)發(fā)生,文中將解決辦法介紹的非常詳細(xì),需要的朋友可以參考下2024-08-08Python OpenCV簡(jiǎn)單的繪圖函數(shù)使用教程
本文主要為大家介紹了OpenCV中一些簡(jiǎn)單的繪圖函數(shù)的使用教程,文中的示例代碼講解詳細(xì),對(duì)我們了解OpenCV有一定的幫助,感興趣的可以學(xué)習(xí)一下2022-01-01python數(shù)據(jù)寫入Excel文件中的實(shí)現(xiàn)步驟
Python作為時(shí)下流行的語(yǔ)言,數(shù)據(jù)寫入Excel是必要的操作,下面這篇文章主要給大家介紹了關(guān)于python數(shù)據(jù)寫入Excel文件中的簡(jiǎn)單實(shí)現(xiàn)方法,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-04-04Django項(xiàng)目在pycharm新建的步驟方法
在本篇文章里小編給大家整理的是一篇關(guān)于Django項(xiàng)目在pycharm新建的步驟方法,有興趣的朋友們可以學(xué)習(xí)參考下。2021-03-03Python利用sqlacodegen自動(dòng)生成ORM實(shí)體類示例
這篇文章主要介紹了Python利用sqlacodegen自動(dòng)生成ORM實(shí)體類,結(jié)合實(shí)例形式分析了Python sqlacodegen安裝技巧ORM實(shí)體類相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2019-06-06深入理解Python虛擬機(jī)中常見(jiàn)魔術(shù)方法的使用
本文主要給大家介紹在 python 當(dāng)中與數(shù)學(xué)計(jì)算相關(guān)的一些常見(jiàn)的魔術(shù)方法,是在很多科學(xué)計(jì)算的包當(dāng)中都使用到的魔術(shù)方法,感興趣的小伙伴可以了解一下2023-05-05python發(fā)送郵件功能實(shí)現(xiàn)代碼
這篇文章主要為大家詳細(xì)介紹了python發(fā)送郵件功能實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-07-07python如何調(diào)用php文件中的函數(shù)詳解
這篇文章主要給大家介紹了關(guān)于python如何調(diào)用php文件中函數(shù)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12