VTK OrientationMarker 方向 三维坐标系 相机坐标轴 自定义坐标轴

本文 以 Python 语言开发

我们在做三维软件开发时,经常会用到相机坐标轴,来指示当前空间位置;

坐标轴效果:

相机方向坐标轴

 Cube 正方体坐标轴

 自定义坐标轴:

Code:

Axes
def main():colors = vtkNamedColors()# create a SpheresphereSource = vtkSphereSource()sphereSource.SetCenter(0.0, 0.0, 0.0)sphereSource.SetRadius(0.5)# create a mappersphereMapper = vtkPolyDataMapper()sphereMapper.SetInputConnection(sphereSource.GetOutputPort())# create an actorsphereActor = vtkActor()sphereActor.SetMapper(sphereMapper)# a renderer and render windowrenderer = vtkRenderer()renderWindow = vtkRenderWindow()renderWindow.SetWindowName('Axes')renderWindow.AddRenderer(renderer)# an interactorrenderWindowInteractor = vtkRenderWindowInteractor()renderWindowInteractor.SetRenderWindow(renderWindow)# add the actors to the scenerenderer.AddActor(sphereActor)renderer.SetBackground(colors.GetColor3d('SlateGray'))transform = vtkTransform()transform.Translate(1.0, 0.0, 0.0)axes = vtkAxesActor()#  The axes are positioned with a user transformaxes.SetUserTransform(transform)# properties of the axes labels can be set as follows# this sets the x axis label to redaxes.GetXAxisCaptionActor2D().GetCaptionTextProperty().SetColor(colors.GetColor3d('Red'));# the actual text of the axis label can be changed:axes.SetXAxisLabelText('test')renderer.AddActor(axes)renderer.GetActiveCamera().Azimuth(50)renderer.GetActiveCamera().Elevation(-30)renderer.ResetCamera()renderWindow.SetWindowName('Axes')renderWindow.Render()# begin mouse interactionrenderWindowInteractor.Start()if __name__ == '__main__':main()
CameraOrientationWidget
def main():colors = vtkNamedColors()renderer = vtkRenderer()ren_win = vtkRenderWindow()interactor = vtkRenderWindowInteractor()sphere_source = vtkSphereSource()sphere_source.SetRadius(10.0)mapper = vtkPolyDataMapper()mapper.SetInputConnection(sphere_source.GetOutputPort())actor = vtkActor()actor.GetProperty().SetColor(colors.GetColor3d('Beige'))actor.SetMapper(mapper)renderer.AddActor(actor)renderer.SetBackground(colors.GetColor3d('DimGray'))ren_win.AddRenderer(renderer)ren_win.SetSize(600, 600)ren_win.SetWindowName('CameraOrientationWidget')# Important: The interactor must be set prior to enabling the widget.interactor.SetRenderWindow(ren_win)cam_orient_manipulator = vtkCameraOrientationWidget()cam_orient_manipulator.SetParentRenderer(renderer)# Enable the widget.cam_orient_manipulator.On()ren_win.Render()interactor.Initialize()interactor.Start()if __name__ == "__main__":main()
OrientationMarkerWidget
   colors = vtkNamedColors()# create a rendering window and rendererren = vtkRenderer()ren_win = vtkRenderWindow()ren_win.AddRenderer(ren)ren_win.SetWindowName('OrientationMarkerWidget')# create a renderwindowinteractoriren = vtkRenderWindowInteractor()iren.SetRenderWindow(ren_win)cube = vtkCubeSource()cube.SetXLength(200)cube.SetYLength(200)cube.SetZLength(200)cube.Update()cm = vtkPolyDataMapper()cm.SetInputConnection(cube.GetOutputPort())ca = vtkActor()ca.SetMapper(cm)ca.GetProperty().SetColor(colors.GetColor3d("BurlyWood"))ca.GetProperty().EdgeVisibilityOn()ca.GetProperty().SetEdgeColor(colors.GetColor3d("Red"))# assign actor to the rendererren.AddActor(ca)ren.SetBackground(colors.GetColor3d('CornflowerBlue'))axes_actor = vtkAnnotatedCubeActor()axes_actor.SetXPlusFaceText('L')axes_actor.SetXMinusFaceText('R')axes_actor.SetYMinusFaceText('I')axes_actor.SetYPlusFaceText('S')axes_actor.SetZMinusFaceText('P')axes_actor.SetZPlusFaceText('A')axes_actor.GetTextEdgesProperty().SetColor(colors.GetColor3d("Yellow"))axes_actor.GetTextEdgesProperty().SetLineWidth(2)axes_actor.GetCubeProperty().SetColor(colors.GetColor3d("Blue"))axes = vtkOrientationMarkerWidget()axes.SetOrientationMarker(axes_actor)axes.SetInteractor(iren)axes.EnabledOn()axes.InteractiveOn()ren.ResetCamera()# enable user interface interactoriren.Initialize()ren_win.Render()ren.GetActiveCamera().Azimuth(45)ren.GetActiveCamera().Elevation(30)ren_win.Render()iren.Start()
custom OrientationMarker
    colors = vtkNamedColors()reader = vtkXMLPolyDataReader()reader.SetFileName("./Human.vtp")icon_mapper = vtkDataSetMapper()icon_mapper.SetInputConnection(reader.GetOutputPort())icon_actor = vtkActor()icon_actor.SetMapper(icon_mapper)icon_actor.GetProperty().SetColor(colors.GetColor3d('Silver'))# Set up the renderer, window, and interactorrenderer = vtkRenderer()renderer.SetBackground(colors.GetColor3d('SlateGray'))ren_win = vtkRenderWindow()ren_win.AddRenderer(renderer)ren_win.SetSize(400, 400)ren_win.SetWindowName('OrientationMarkerWidget1')iren = vtkRenderWindowInteractor()iren.SetRenderWindow(ren_win)rgb = [0.0, 0.0, 0.0]colors.GetColorRGB('Wheat', rgb)# Set up the widgetwidget = vtkOrientationMarkerWidget()widget.SetOrientationMarker(icon_actor)widget.SetInteractor(iren)widget.SetViewport(0.0, 0.0, 0.3, 0.3)widget.SetOutlineColor(*rgb)widget.SetEnabled(1)widget.InteractiveOn()# Create a superquadricsuperquadric_source = vtkSuperquadricSource()superquadric_source.SetPhiRoundness(.001)superquadric_source.SetThetaRoundness(.04)# Create a mapper and actorsuperquadric_mapper = vtkPolyDataMapper()superquadric_mapper.SetInputConnection(superquadric_source.GetOutputPort())superquadric_actor = vtkActor()superquadric_actor.SetMapper(superquadric_mapper)superquadric_actor.GetProperty().SetInterpolationToFlat()superquadric_actor.GetProperty().SetDiffuseColor(colors.GetColor3d('Carrot'))superquadric_actor.GetProperty().SetSpecularColor(colors.GetColor3d('White'))superquadric_actor.GetProperty().SetDiffuse(0.6)superquadric_actor.GetProperty().SetSpecular(0.5)superquadric_actor.GetProperty().SetSpecularPower(5.0)renderer.AddActor(superquadric_actor)renderer.ResetCamera()ren_win.Render()iren.Initialize()iren.Start()

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/121656.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

(四)库存超卖案例实战——优化redis分布式锁

前言 在上一节内容中,我们已经实现了使用redis分布式锁解决商品“超卖”的问题,本节内容是对redis分布式锁的优化。在上一节的redis分布式锁中,我们的锁有俩个可以优化的问题。第一,锁需要实现可重入,同一个线程不用重…

机器学习之朴素贝叶斯

朴素贝叶斯: 也叫贝叶算法推断,建立在主管判断的基础上,不断地进行地修正。需要大量的计算。1、主观性强2、大量计算 贝叶斯定理:有先验概率和后验概率区别:假如出门堵车有两个因素:车太多与交通事故先验概…

归结原理、归结演绎推理

主要内容 归结演绎推理范式子句与子句集将谓词公式转化为子句集命题逻辑鲁宾逊归结原理 归结演绎推理 定理证明的实质是对前提P和结论Q证明P →Q的永真性应用反证法,欲证明P →Q,只要证明 P∧~Q 等价于 F鲁宾逊归结原理对机械化推理有重大突破鲁宾逊归…

Linux—vmstat命令详解

vmstat概念 vmstat命令是 Virtual Meomory Statistics(虚拟内存统计)的缩写,可用来动态监控系统资源的 CPU 使用、进程状态、内存使用、虚拟内存使用、硬盘输入/输出状态等信息使用情况 vmstat下载 yum -y install sysstat vmstat命令参数…

XJ+Nreal 高精度地图+Nreal眼镜SDK到发布APK至眼镜中

仅支持Anroid平台 Nreal套装自带的计算单元,其实也是⼀个没有显示器的Android设备 新建unity⼯程,将⼯程切换Android平台。 正在上传…重新上传取消正在上传…重新上传取消 Cloud XDK Unity User Manual for Nreal ARGlasses 该XDK是针对 NReal AR 眼镜…

vue axios请求两种方式,出现401错误,需要添加config配置

file文件的转化 const uint8Array xxxxx;//总之先拿到uint8Array 格式的话 let mBuffer Buffer.from(uint8Array); //转buffer this.mBlob new Blob([mBuffer], { type: application/pdf;charsetutf-8 }); //这里是转blob this.mFile new File([this.mBlob], merged.pdf, …

网络基础-4

链路聚合技术 根据灵活性地增加网络设备之间的带宽供给增强网络设备之间连接的可靠性节约成本 链路聚合 是将两个或更多数据信道结合成一个单个的信道,该信道以一个单个的更高带宽的逻辑链路出现。链路聚合一般用来连接一个或多个带宽需求大的设备,例…

Vue $nextTick

我们用一个例子来说明$nextTick的作用: 我们用一个变量showIpt来控制input框的显示和隐藏,默认是隐藏。 我们点击一个按钮后显示这个输入框的同时,input还要自动获取焦点。 但是我们点击按钮过后并没有生效。 为什么?this.show…

【PG】PostgreSQL客户端认证pg_hba.conf文件

目录 文件格式 连接类型(TYPE) 数据库(database) 用户(user) 连接地址(address) 格式 IPv4 IPv6 字符 主机名 主机名后缀 IP-address/IP-mask auth-method trust reject scram-sha-256 md5 password gss sspi …

23种设计模式【创建型模式】详细介绍之【建造者模式】

建造者模式:构建复杂对象的精妙设计 设计模式的分类和应用场景总结建造者模式:构建复杂对象的精妙设计建造者模式的核心思想建造者模式的参与者Java示例:建造者模式 设计模式的分类和应用场景总结 可以查看专栏设计模式:设计模式 …

STM32中除零运算,为何程序不崩溃?

在 C 语言中,除零运算会导致异常吗? 在 C 语言中,当一个数除以零时,会导致除法运算错误,通常表现为“除以零”错误或被称为“浮点异常”(floating-point exception)。 对于整数除法&#xff0c…

RHCE---正则表达式

文章目录 前言一、pandas是什么?二、使用步骤 1.引入库2.读入数据总结 前言 一. 文本搜索工具 grep是linux中一种强大的文件搜索过滤工具,可以按照正 则表达式检索文件内容,并把匹配的结果显示到屏幕上 (匹配的内容会标红&#x…

设计模式(15)组合模式

一、介绍: 1、定义:组合多个对象形成树形结构以表示“整体-部分”的关系的层次结构。组合模式对叶子节点和容器节点的处理具有一致性,又称为整体-部分模式。 2、优缺点: 优点: (1)高层模块调…

JAVA设计模式详解(独家AI解析)

JAVA设计模式详解(独家AI解析) 一、JAVA介绍二、JAVA设计模式六大原则三、JAVA设计模式介绍四、JAVA设计模式详解4.1 单例模式4.1.1 懒汉式(Lazy Initialization)4.1.2 饿汉式(Lazy Initialization) 4.2 代…

UE4/5 竖排文字文本

方法一、使用多行文本组件 新建一个Widget Blueprint 添加Text 或者 Editable Text(Multi-Line) 、TextBox(Multi-Line) 组件。 添加文字,调整字号,调整成竖排文字。 在Wrapping (换行)面板中 : 勾选 Auto Wrap te…

RabbitMQ的交换机(原理及代码实现)

1.交换机类型 Fanout Exchange(扇形)Direct Exchange(直连)opic Exchange(主题)Headers Exchange(头部) 2.Fanout Exchange 2.1 简介 Fanout 扇形的,散开的&#xff1…

pve lxc debian 11安装docker遇到bash: sudo: command not解决办法

pve创建LXC容器,使用debian 11模版,安装完成后正常换源、安装依赖 然后添加Docker 的官方 GPG 密钥时出错: $ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | sudo apt-key add - 提示 bash: sudo: command not …

基于图像识别的自动驾驶汽车障碍物检测与避障算法研究

基于图像识别的自动驾驶汽车障碍物检测与避障算法研究是一个涉及计算机视觉、机器学习、人工智能和自动控制等多个领域的复杂问题。以下是对这个问题的研究内容和方向的一些概述。 障碍物检测 障碍物检测是自动驾驶汽车避障算法的核心部分,它需要从车辆的感知数据…

统计学习方法 决策树

文章目录 统计学习方法 决策树决策树模型与学习特征选择决策树的生成ID3 算法C4.5 的生成算法 决策树的剪枝CART 算法CART 回归树的生成CART 分类树的生成CART 剪枝 统计学习方法 决策树 阅读李航的《统计学习方法》时,关于决策树的笔记。 决策树模型与学习 决策…

git 删除远程标签tag【杂记】

分为两步: 1、删除本地tag git tag -d tag-name 2、删除远程tag git push origin :refs/tags/tag-name