当前位置:网站首页>SlicePlane的Heading角度与Math.atan2(y,x)的对应转换关系
SlicePlane的Heading角度与Math.atan2(y,x)的对应转换关系
2022-06-28 05:05:00 【Higer2008】
对三维模型提进行剖切,想同时有多个剖切面(类似于连井剖面),查API构造SlicePlane可以实现,但在heading这个参数设置时遇到了一些麻烦,这里记录下,供大家参考。
想多个面剖切,需根据多个节点构造剖切面即SlicePlane,该面的构造需要如下参数:中心点,tilt(俯仰角),width,height和heading(我称之为航向角),示意图如上,代码如下:
let sliceWidget = new Slice({
view: view
});
sliceWidget.viewModel.shape = new SlicePlane({
position: new Point({
latitude: 34.06007911204149,
longitude: -117.1867758409791,
z: 416.852
}),
// a 30 degree angle between the slice plane and the ground plane
tilt: 30,
width: 32,
height: 32,
// the height axis of the plane is oriented north
heading: 0
});
sliceWidget.viewModel.start();
view.ui.add(sliceWidget, "top-right");
构造完毕后,按照如下代码,添加到Sceneview的analyses里即可。当然每次添加前可以先调用removeAll()方法清空。
// Adds an analysis to the View
view.analyses.add(lineOfSightAnalysis);
// Removes an analysis from the View
view.analyses.remove(lineOfSightAnalysis);
在构造时根据选点P1和P2计算width,heading参数,在计算heading参数时,本人使用的是Math.atan2(y,x),因两者对角度的定义,起算点,顺逆方向不一致,需要进行转换才能得出对应的正确角度,传递给SlicePlane的构造函数。经测试,不同象限的转换关系如下:
Math.atan2(y,x)是以弧度为单位
heading是以degree为单位的
- 将第一个点视为原点,当第二个点相对于第一个点位于一、四象限时,
heading = - atan2(p2.y-p1.y,p2.x-p1.x)/(Math.pi/180) - 将第一个点视为原点,当第二个点相对于第一个点位于二、三象限时,
heading = 180 - atan2(p2.y-p1.y,p2.x-p1.x)/(Math.pi/180)

边栏推荐
猜你喜欢

LeetCode 88:合并两个有序数组

学习太极创客 — MQTT 第二章(五)心跳机制

Project practice! Teach you JMeter performance test hand in hand

2022新版nft源码中国元宇宙数字藏品艺术品交易平台源码

别卷!如何高质量地复现一篇论文?

Extjs library management system source code intelligent library management system source code

Idle interrupt cannot be cleared

CPG 固体支持物研究:Lumiprobe通用 CPG II 型

CI & CD must be known!

Where does the storm go? Whose pot is the weather forecast wrong?
随机推荐
cgo+gSoap+onvif学习总结:8、arm平台交叉编译运行及常见问题总结
Sword finger offer 47 Maximum gift value (DP)
为什么大厂不让使用undefined
【牛客网刷题系列 之 Verilog快速入门】~ 四选一多路器
PHP code wechat, official account and enterprise wechat send emoticons [u+1f449]
2022西式面点师(高级)考试试题模拟考试平台操作
Reactive dye research: lumiprobe af594 NHS ester, 5-isomer
Learn Taiji Maker - mqtt Chapter 2 (IV) esp8266 reserved message application
Function and working principle of controller
2022 high altitude installation, maintenance and removal examination questions and answers
学习太极创客 — MQTT 第二章(四)ESP8266 保留消息应用
创新之源 理解通透 二
Unity out ref params
Principle and implementation of SSD for target detection
Unity delegate
高通平台 Camera 之 MCLK 配置
Unity delegate
Have you finished the examination of level II cost engineer? There are also qualification regulations!
mysql----where 1=1是什么意思
大促场景下,如何做好网关高可用防护