詳解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引入多個(gè)模塊及包的概念過(guò)程解析
這篇文章主要介紹了Python引入多個(gè)模塊及包的概念過(guò)程解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-09-09
Linux下使用python腳本執(zhí)行BCP導(dǎo)入導(dǎo)出方式
這篇文章主要介紹了Linux下使用python腳本執(zhí)行BCP導(dǎo)入導(dǎo)出方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-01-01
Python辦公自動(dòng)化PPT批量轉(zhuǎn)換操作
本文介紹如何使用 python 操作 PPT,用到的模塊就是 python-pptx,以下的示例基本滿足日常需求,如果要知道更多,可以訪問(wèn) python-pptx 的官方文檔2021-09-09
Python操作MySQL數(shù)據(jù)庫(kù)的入門(mén)指南
MySQL是一種關(guān)系型數(shù)據(jù)庫(kù)管理系統(tǒng),廣泛應(yīng)用于各種應(yīng)用程序和網(wǎng)站,在本篇技術(shù)博客中,我們將探討如何使用Python操作MySQL數(shù)據(jù)庫(kù),需要的可以收藏一下2023-06-06
Django請(qǐng)求響應(yīng)Web Http交互的核心機(jī)制深入理解
本文深入探討了 Django 中的請(qǐng)求與響應(yīng)處理,從 Django 請(qǐng)求和響應(yīng)的基礎(chǔ)知識(shí)、生命周期,到 HttpRequest 和 HttpResponse 對(duì)象的詳細(xì)介紹,同時(shí),討論了 Django 的視圖和請(qǐng)求、響應(yīng)處理,以及安全性和異步處理的考慮2023-09-09
Python中虛擬環(huán)境依賴(lài)問(wèn)題的解決方案詳解
在Python開(kāi)發(fā)中,虛擬環(huán)境和依賴(lài)管理是必不可少的工具,本文將以一個(gè)實(shí)際案例為基礎(chǔ),詳細(xì)分析如何解決Python虛擬環(huán)境中的依賴(lài)問(wèn)題,希望對(duì)大家有所幫助2025-03-03
Python列表中多元素刪除(移除)的實(shí)現(xiàn)
本文主要介紹了Python列表中多元素刪除(移除)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-03-03

