详解python polyscope库的安装和例程

 更新时间:2020年11月13日 16:55:42   作者:世纪末的尾字母  
这篇文章主要介绍了python polyscope库的安装和例程,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

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

pip install polyscope

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

在这里插入图片描述

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

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,我的解决办法是在这个目录下面还应该有一个这个文件:

在这里插入图片描述

把他的名字改成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使用pdb调试代码的技巧

    Python使用pdb调试代码的技巧

    Pdb就是Python debugger,是python自带的调试器。这篇文章主要介绍了Python使用pdb调试代码的技巧,需要的朋友可以参考下
    2020-05-05
  • Python引入多个模块及包的概念过程解析

    Python引入多个模块及包的概念过程解析

    这篇文章主要介绍了Python引入多个模块及包的概念过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2020-09-09
  • wxPython+Matplotlib绘制折线图表

    wxPython+Matplotlib绘制折线图表

    这篇文章主要介绍了wxPython+Matplotlib绘制折线图表,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2019-11-11
  • Linux下使用python脚本执行BCP导入导出方式

    Linux下使用python脚本执行BCP导入导出方式

    这篇文章主要介绍了Linux下使用python脚本执行BCP导入导出方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2024-01-01
  • Python办公自动化PPT批量转换操作

    Python办公自动化PPT批量转换操作

    本文介绍如何使用 python 操作 PPT,用到的模块就是 python-pptx,以下的示例基本满足日常需求,如果要知道更多,可以访问 python-pptx 的官方文档
    2021-09-09
  • Python操作MySQL数据库的入门指南

    Python操作MySQL数据库的入门指南

    MySQL是一种关系型数据库管理系统,广泛应用于各种应用程序和网站,在本篇技术博客中,我们将探讨如何使用Python操作MySQL数据库,需要的可以收藏一下
    2023-06-06
  • Django请求响应Web Http交互的核心机制深入理解

    Django请求响应Web Http交互的核心机制深入理解

    本文深入探讨了 Django 中的请求与响应处理,从 Django 请求和响应的基础知识、生命周期,到 HttpRequest 和 HttpResponse 对象的详细介绍,同时,讨论了 Django 的视图和请求、响应处理,以及安全性和异步处理的考虑
    2023-09-09
  • Python中虚拟环境依赖问题的解决方案详解

    Python中虚拟环境依赖问题的解决方案详解

    在Python开发中,虚拟环境和依赖管理是必不可少的工具,本文将以一个实际案例为基础,详细分析如何解决Python虚拟环境中的依赖问题,希望对大家有所帮助
    2025-03-03
  • Python retrying 重试机制的使用方法

    Python retrying 重试机制的使用方法

    我们在程序开发中,经常会需要请求一些外部的接口资源,而且我们不能保证每次请求一定会成功,所以这些涉及到网络请求的代码片段就需要加上重试机制。本文就来详细的介绍一下,感兴趣的可以了解一下
    2021-09-09
  • Python列表中多元素删除(移除)的实现

    Python列表中多元素删除(移除)的实现

    本文主要介绍了Python列表中多元素删除(移除)的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2023-03-03

最新评论