SlicePlane的Heading角度与Math.atan2(y,x)的对应转换关系

对三维模型提进行剖切,想同时有多个剖切面(类似于连井剖面),查API构造SlicePlane可以实现,但在heading这个参数设置时遇到了一些麻烦,这里记录下,供大家参考。
SlicePlane
想多个面剖切,需根据多个节点构造剖切面即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()方法清空。
SceneView

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

    1和4象限的转换关系
    2/3象限时的转换关系
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Higer2008

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值