详解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 相关文章推荐
总结用Pdb库调试Python的方式及常用的命令
Aug 18 Python
使用pandas中的DataFrame数据绘制柱状图的方法
Apr 10 Python
浅谈python标准库--functools.partial
Mar 13 Python
selenium+python自动化测试环境搭建步骤
Jun 03 Python
Python中函数参数匹配模型详解
Jun 09 Python
python 实现识别图片上的数字
Jul 30 Python
pandas的相关系数与协方差实例
Dec 27 Python
python计算波峰波谷值的方法(极值点)
Feb 18 Python
pip install 使用国内镜像的方法示例
Apr 03 Python
python读取hdfs并返回dataframe教程
Jun 05 Python
Python利用matplotlib绘制折线图的新手教程
Nov 05 Python
Python可视化神器pyecharts之绘制箱形图
Jul 07 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
php反弹shell实现代码
2009/04/22 PHP
Mysql的Root密码忘记,查看或修改的解决方法(图文介绍)
2013/06/14 PHP
PHP 实现公历日期与农历日期的互转换
2017/09/13 PHP
JavaScript 创建对象和构造类实现代码
2009/07/30 Javascript
基于jquery的一个浮动框(扩展性比较好 )
2010/08/27 Javascript
获取offsetTop和offsetLeft值的js代码(兼容)
2013/04/16 Javascript
JavaScript获取onclick、onchange等事件值的代码
2013/07/22 Javascript
JavaScript 中的日期和时间及表示标准介绍
2013/08/21 Javascript
Jquery使用Firefox FireBug插件调试Ajax步骤讲解
2013/12/02 Javascript
js的Prototype属性解释及常用方法
2014/05/08 Javascript
jquery 实现两Select 标签项互调示例代码
2014/09/25 Javascript
JQuery使用index方法获取Jquery对象数组下标的方法
2015/05/18 Javascript
JavaScript兼容浏览器FF/IE技巧
2016/08/14 Javascript
jQuery实现的简单动态添加、删除表格功能示例
2017/09/21 jQuery
微信小程序tabBar模板用法实例分析【附demo源码下载】
2017/11/28 Javascript
微信小程序实战篇之购物车的实现代码示例
2017/11/30 Javascript
小程序server请求微信服务器超时的解决方法
2019/05/21 Javascript
JS实现水平移动与垂直移动动画
2019/12/19 Javascript
vue实现div单选多选功能
2020/07/16 Javascript
vue实现给div绑定keyup的enter事件
2020/07/31 Javascript
tornado捕获和处理404错误的方法
2014/02/26 Python
python远程邮件控制电脑升级版
2019/05/23 Python
Python中remove漏删和索引越界问题的解决
2020/03/18 Python
pycharm无法安装第三方库的问题及解决方法以scrapy为例(图解)
2020/05/09 Python
Python 跨.py文件调用自定义函数说明
2020/06/01 Python
Python3爬虫发送请求的知识点实例
2020/07/30 Python
Pytho爬虫中Requests设置请求头Headers的方法
2020/09/22 Python
娇韵诗加拿大官网:Clarins加拿大
2017/11/20 全球购物
浙大网新C/C++面试解惑
2015/05/27 面试题
Python的两道面试题
2013/06/29 面试题
记者岗位职责
2014/01/06 职场文书
万能检讨书开头与结尾怎么写
2015/02/17 职场文书
横空出世观后感
2015/06/09 职场文书
python基于机器学习预测股票交易信号
2021/05/25 Python
JavaScript 中for/of,for/in 的详细介绍
2021/11/17 Javascript
php png失真的原因及解决办法
2021/11/17 PHP