详解python polyscope库的安装和例程


Posted in Python onNovember 13, 2020

安装就可以在环境配置好的情况下使用pip安装:

pip install polyscope

如果提示找不到库文件,no moudle的话可以试着把安装下来的polyscope文件夹放在和想要运行的py文件的同一目录下。
而我们安装下来的polyscope文件夹在哪里呢?它们应该位于安装目录中的"Lib/site-packages"中,我的如下图所示:

详解python polyscope库的安装和例程

但是装好之后我们运行一个网上的例程:

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()

还是有错误,找不到polyscope_bindings,我的解决办法是在这个目录下面还应该有一个这个文件:

详解python polyscope库的安装和例程

把他的名字改成polyscope_bindings.pyd就可以解决,库就可以跑通了。但是原例程因为没有给数组所有还有逻辑错误,随便给几个就可以运行了:

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()

这就可以成功使用了

详解python polyscope库的安装和例程

到此这篇关于python polyscope库的安装和例程的文章就介绍到这了,更多相关python polyscope库内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!

Python 相关文章推荐
Python的Flask框架应用调用Redis队列数据的方法
Jun 06 Python
django之session与分页(实例讲解)
Nov 13 Python
Python cookbook(数据结构与算法)字典相关计算问题示例
Feb 18 Python
浅谈Series和DataFrame中的sort_index方法
Jun 07 Python
python语音识别实践之百度语音API
Aug 30 Python
Python 调用 zabbix api的方法示例
Jan 06 Python
使用tensorflow框架在Colab上跑通猫狗识别代码
Apr 26 Python
Python requests.post方法中data与json参数区别详解
Apr 30 Python
pycharm如何使用anaconda中的各种包(操作步骤)
Jul 31 Python
Python 在局部变量域中执行代码
Aug 07 Python
pytest fixtures装饰器的使用和如何控制用例的执行顺序
Jan 28 Python
用python修改excel表某一列内容的操作方法
Jun 11 Python
python中的测试框架
Nov 13 #Python
Python加载数据的5种不同方式(收藏)
Nov 13 #Python
使用Python解析Chrome浏览器书签的示例
Nov 13 #Python
python 实现围棋游戏(纯tkinter gui)
Nov 13 #Python
python3从网络摄像机解析mjpeg http流的示例
Nov 13 #Python
python+flask编写一个简单的登录接口
Nov 13 #Python
jupyter notebook快速入门及使用详解
Nov 13 #Python
You might like
第四节 构造函数和析构函数 [4]
2006/10/09 PHP
php判断类是否存在函数class_exists用法分析
2014/11/14 PHP
php对关联数组循环遍历的实现方法
2015/03/13 PHP
Codeigniter实现发送带附件的邮件
2015/03/19 PHP
PHP中foreach()用法汇总
2015/07/02 PHP
PHP 进度条函数的简单实例
2017/09/19 PHP
php爬取天猫和淘宝商品数据
2018/02/23 PHP
PHP ajax+jQuery 实现批量删除功能实例代码小结
2018/12/06 PHP
php + ajax 实现的写入数据库操作简单示例
2020/05/16 PHP
纯js实现的论坛常用的运行代码的效果
2008/07/15 Javascript
js实现图片旋转的三种方法
2014/04/10 Javascript
关闭页面时window.location事件未执行的原因分析及解决方案
2014/09/01 Javascript
JavaScript动态提示输入框输入字数的方法
2015/07/27 Javascript
详解js私有作用域中创建特权方法
2016/01/25 Javascript
jQuery模仿单选按钮选中效果
2016/06/24 Javascript
AngularJS基础 ng-csp 指令详解
2016/08/01 Javascript
分享bootstrap学习笔记心得(组件及其属性)
2017/01/11 Javascript
使用jQuery实现掷骰子游戏
2019/10/24 jQuery
vue通过v-html指令渲染的富文本无法修改样式的解决方案
2020/05/20 Javascript
uni-app微信小程序登录授权的实现
2020/05/22 Javascript
vue中利用three.js实现全景图的完整示例
2020/12/07 Vue.js
[08:38]DOTA2-DPC中国联赛 正赛 VG vs Elephant 选手采访
2021/03/11 DOTA
python time模块用法实例详解
2014/09/11 Python
pygame实现简易飞机大战
2018/09/11 Python
Python动态强类型解释型语言原理解析
2020/03/25 Python
北美领先的牛仔品牌:Buffalo David Bitton
2017/05/22 全球购物
凯撒娱乐:Caesars Entertainment
2018/02/23 全球购物
周鸿祎:教你写创业计划书
2013/12/30 职场文书
中学感恩教育活动总结
2015/05/05 职场文书
2015年幼儿园学期工作总结
2015/05/22 职场文书
2015年计算机教学工作总结
2015/07/22 职场文书
新学期开学寄语2016
2015/12/04 职场文书
浅谈Golang 切片(slice)扩容机制的原理
2021/06/09 Golang
Go并发4种方法简明讲解
2022/04/06 Golang
Elasticsearch 批量操作
2022/04/19 Python
Nginx报错104:Connection reset by peer问题的解决及分析
2022/07/23 Servers