当前位置: 首页 > news >正文

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

相关文章:

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

本文 以 Python 语言开发 我们在做三维软件开发时,经常会用到相机坐标轴,来指示当前空间位置; 坐标轴效果: 相机方向坐标轴 Cube 正方体坐标轴 自定义坐标轴: Code: Axes def main():colors vtkNamedC…...

工控安全与网络安全有什么不同?

在当代,全球制造业正在经历一场前所未有的技术变革。工业4.0不仅代表着自动化和数据交换的进步,它还揭示了工业自动化、智能制造与系统集成的融合。这种集成为企业带来了效率和质量的双重提升,但同时也暴露出新的安全隐患。工控系统成为了这一…...

性能测试工具:Jmeter介绍

JMeter是一个开源的Java应用程序,由Apache软件基金会开发和维护,可用于性能测试、压力测试、接口测试等。 1. 原理 JMeter的基本原理是模拟多用户并发访问应用程序,通过发送HTTP请求或其他协议请求,并测量响应时间、吞吐量、并发…...

Golang Struct 继承的深入讨论和细节

1)结构体可以使用嵌套匿名结构体所有的字段和方法,即:首字母大写或者小写的字段、方法,都可以使用。 type A struct {Name stringage int }func (a *A) SayName() {fmt.Println("A say name", a.Name) }func (a *A) s…...

Android11分区介绍

1.分区汇总 3566及3568分区对应如下: rockdev/Image-rk3566_rgo/ ├── boot.img ├── dtbo.img ├── MiniLoaderAll.bin ├── misc.img ├── parameter.txt ├── recovery.img ├── super.img ├── uboot.img └── vbmeta.img 2.分区说明 分区 说明 boo…...

goland无法调试问题解决

goland 无法调试问题解决 golang 版本升级后,goland 无法进行调试了 首先请看自己下载的版本是否有误 1.apple系 M系列芯片的 arm64版本 2.apple系 intel系列芯片的x86_64 3.windows系 intel解决如下: 查看gopath ericsanchezErics-Mac-mini gww-api…...

关于近期IP-Guard新版本客户端重复发送邮件的问题处理说明

关于近期新版本客户端重复发送邮件的问题处理说明 一、问题描述 近期部分客户反馈,升级到新版本的客户端(4.81.341.0、4.82.621.0及以上),使用SMTP协议发送邮件时,会出现重复发送邮件的情况,主要表现为以下两种现象: Outlook发送包含大量收件人的邮件时,收件人邮箱可能…...

linux java 启动脚本

#!/bin/sh## java env #export JAVA_HOME/data/jdk1.8.0_121 #export JRE_HOME$JAVA_HOME/jre## service name #当前目录 SERVICE_DIR$(cd dirname $0; pwd) echo "$SERVICE_DIR" #jar包路径 JAR_DIRls -ltr $SERVICE_DIR/*.jar| tail -1 echo "JAR_DIR $JAR_DI…...

Node.js 的 CommonJS ECMAScript 标准用法

目录 一、前言二、CommonJS 标准使用方法 三、ECMAScript 标准使用方法 四、常用命令总结 一、前言 本文主要是介绍 Node.js 的 CommonJS & ECMAScript 标准用法 如果对你有帮助,欢迎三连 收藏点赞关注!!! ---- NickYoung 二、…...

Mysql数据库 4.SQL语言 DQL数据查询语言 查询

DQL数据查询语言 从数据表中提取满足特定条件的记录 1.单表查询 2.多表查询 查询基础语法 select 关键字后指定要查询到的记录的哪些列 语法:select 列名(字段名)/某几列/全部列 from 表名 [具体条件]; select colnumName…...

俄罗斯黑客利用Roundcube零日漏洞窃取政府电子邮件

导语:最近,一起涉及Roundcube Webmail的零日漏洞被俄罗斯黑客组织Winter Vivern利用,攻击了欧洲政府机构和智库。这一漏洞已经存在至少一个月,直到10月16日,Roundcube开发团队才发布了安全补丁来修复这个Stored Cross-…...

【Javascript】ajax(阿甲克斯)

目录 什么是ajax? 同步与异步 原理 注意 写一个ajax请求 创建ajax对象 设置请求方式和地址 发送请求 设置响应HTTP请求状态变化的函数 什么是ajax? 是基于javascript的一种用于创建快速动态网页的技术,是一种在无需重新加载整个网页的情况下&#xff0c…...

Spring MVC的常用注解

目录 RequestMapping 例子: RequestMapping 支持什么类型的请求 使 RequestMapping 只支持特定的类型 RestController 通过 HTTP 请求传递参数给后端 1.传递单个参数 注意使⽤基本类型来接收参数的情况 2.传递多个参数 3.传递对象 4.RequestParam 后端参数…...

vim 使用文档笔记

1. i:进入编辑模式 2. ESC:进入一般命令模式 3. h 或 ←:光标向左移动一个字符 4. j 或 ↓:光标向下移动一个字符 5. k 或 ↑:光标向上移动一个字符 6. l 或 →:光标向右移动一个字符 7. num&#xf…...

274. H 指数

文章目录 一、题目1、题目描述2、基础框架3、原题链接 二、解题报告1、思路分析1.1 方案一1.2 方案二 2、时间复杂度3、代码详解3.1 方案一3.2 方案二 三、本题小知识 一、题目 1、题目描述 给你一个整数数组 citations ,其中 citations[i] 表示研究者的第 i 篇论…...

0基础学习PyFlink——用户自定义函数之UDTAF

大纲 UDTAFTableAggregateFunction的实现累加器定义创建累加 返回类型计算 完整代码 在前面几篇文章中,我们分别介绍了UDF、UDTF和UDAF这三种用户自定义函数。本节我们将介绍最后一种函数:UDTAF——用户自定义表值聚合函数。 UDTAF UDTAF函数即具备了…...

SQLi靶场

SQLi靶场 less1- less2 (详细讲解) less 1 Error Based-String (字符类型注入) 思路分析 判断是否存在SQL注入 已知参数名为id,输入数值和‘ 单引号‘’ 双引号来判断,它是数值类型还是字符类型 首先输入 1 , 发现…...

重庆开放大学学子们的好帮手

作为一名电大学员,我有幸目睹了一个令人惊叹的学习工具的诞生——电大搜题微信公众号。这个创新应用为重庆开放大学(广播电视大学)的学子们提供了便捷、高效的学习资源,成为他们的得力助手。 重庆开放大学是一所为全日制在职人员提…...

机器学习-学习率:从理论到实战,探索学习率的调整策略

目录 一、引言二、学习率基础定义与解释学习率与梯度下降学习率对模型性能的影响 三、学习率调整策略常量学习率时间衰减自适应学习率AdaGradRMSpropAdam 四、学习率的代码实战环境设置数据和模型常量学习率时间衰减Adam优化器 五、学习率的最佳实践学习率范围测试循环学习率&a…...

【Vue3-Flask-BS架构Web应用】实践笔记1-使用一个bat脚本自动化完整部署环境

前言 近年来,Web开发已经成为计算机科学领域中最热门和多产的领域之一。Python和Vue.js是两个备受欢迎的工具,用于构建现代Web应用程序。在本教程中,我们将探索如何使用这两个工具来创建一个完整的Web项目。我们将完成从安装Python和Vue.js到…...

[特殊字符] 智能合约中的数据是如何在区块链中保持一致的?

🧠 智能合约中的数据是如何在区块链中保持一致的? 为什么所有区块链节点都能得出相同结果?合约调用这么复杂,状态真能保持一致吗?本篇带你从底层视角理解“状态一致性”的真相。 一、智能合约的数据存储在哪里&#xf…...

uniapp微信小程序视频实时流+pc端预览方案

方案类型技术实现是否免费优点缺点适用场景延迟范围开发复杂度​WebSocket图片帧​定时拍照Base64传输✅ 完全免费无需服务器 纯前端实现高延迟高流量 帧率极低个人demo测试 超低频监控500ms-2s⭐⭐​RTMP推流​TRTC/即构SDK推流❌ 付费方案 (部分有免费额度&#x…...

ios苹果系统,js 滑动屏幕、锚定无效

现象:window.addEventListener监听touch无效,划不动屏幕,但是代码逻辑都有执行到。 scrollIntoView也无效。 原因:这是因为 iOS 的触摸事件处理机制和 touch-action: none 的设置有关。ios有太多得交互动作,从而会影响…...

【数据分析】R版IntelliGenes用于生物标志物发现的可解释机器学习

禁止商业或二改转载,仅供自学使用,侵权必究,如需截取部分内容请后台联系作者! 文章目录 介绍流程步骤1. 输入数据2. 特征选择3. 模型训练4. I-Genes 评分计算5. 输出结果 IntelliGenesR 安装包1. 特征选择2. 模型训练和评估3. I-Genes 评分计…...

深度学习习题2

1.如果增加神经网络的宽度,精确度会增加到一个特定阈值后,便开始降低。造成这一现象的可能原因是什么? A、即使增加卷积核的数量,只有少部分的核会被用作预测 B、当卷积核数量增加时,神经网络的预测能力会降低 C、当卷…...

服务器--宝塔命令

一、宝塔面板安装命令 ⚠️ 必须使用 root 用户 或 sudo 权限执行! sudo su - 1. CentOS 系统: yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh2. Ubuntu / Debian 系统…...

MFC 抛体运动模拟:常见问题解决与界面美化

在 MFC 中开发抛体运动模拟程序时,我们常遇到 轨迹残留、无效刷新、视觉单调、物理逻辑瑕疵 等问题。本文将针对这些痛点,详细解析原因并提供解决方案,同时兼顾界面美化,让模拟效果更专业、更高效。 问题一:历史轨迹与小球残影残留 现象 小球运动后,历史位置的 “残影”…...

并发编程 - go版

1.并发编程基础概念 进程和线程 A. 进程是程序在操作系统中的一次执行过程,系统进行资源分配和调度的一个独立单位。B. 线程是进程的一个执行实体,是CPU调度和分派的基本单位,它是比进程更小的能独立运行的基本单位。C.一个进程可以创建和撤销多个线程;同一个进程中…...

【 java 虚拟机知识 第一篇 】

目录 1.内存模型 1.1.JVM内存模型的介绍 1.2.堆和栈的区别 1.3.栈的存储细节 1.4.堆的部分 1.5.程序计数器的作用 1.6.方法区的内容 1.7.字符串池 1.8.引用类型 1.9.内存泄漏与内存溢出 1.10.会出现内存溢出的结构 1.内存模型 1.1.JVM内存模型的介绍 内存模型主要分…...

AD学习(3)

1 PCB封装元素组成及简单的PCB封装创建 封装的组成部分: (1)PCB焊盘:表层的铜 ,top层的铜 (2)管脚序号:用来关联原理图中的管脚的序号,原理图的序号需要和PCB封装一一…...