• 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");
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    构造完毕后,按照如下代码,添加到Sceneview的analyses里即可。当然每次添加前可以先调用removeAll()方法清空。
    SceneView

    // Adds an analysis to the View
    view.analyses.add(lineOfSightAnalysis);
    // Removes an analysis from the View
    view.analyses.remove(lineOfSightAnalysis);
    
    • 1
    • 2
    • 3
    • 4

    在构造时根据选点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象限时的转换关系
  • 相关阅读:
    基于STM32与FreeRTOS的消息传递详解(HAL库)
    springboot @Configuration 注解详解
    深度学习技巧总结
    JVM之垃圾回收与内存分配
    C++入门知识
    【读点论文】Densely Connected Convolutional Networks用残差连接大力出奇迹,进一步叠加特征图,以牺牲显存为代价
    重新认识mysql事务
    IDEA如何将本地项目推送到GitHub上?
    基于 GRU-Attention 的中文文本分类学习记录
    数据分析---matplotlib2
  • 原文地址:https://blog.csdn.net/Higer2008/article/details/125482876