RtkControl.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class RtkControl : MonoBehaviour
  5. {
  6. private static RtkControl instance = null;
  7. private static readonly object padlock = new object();
  8. RtkControl() { }
  9. public static RtkControl Instance
  10. {
  11. get
  12. {
  13. lock(padlock)
  14. {
  15. if (instance == null)
  16. instance = new RtkControl();
  17. return instance;
  18. }
  19. }
  20. }
  21. /// <summary>
  22. /// 获取在当前RTK坐标内 物体应该出现在场景中的位置
  23. /// </summary>
  24. /// <param name="rtkPos"> 测量标定的RTK </param>
  25. /// <param name="currentRtkPos"> 当前位置的RTK </param>
  26. /// <param name="playPos"> 设备所在场景中的位置 </param>
  27. /// <param name="posY"> 返回位置的高度 </param>
  28. /// <returns></returns>
  29. public Vector3 SetRtkPos( Vector2 rtkPos , Vector2 currentRtkPos , Vector3 playPos , float posY)
  30. {
  31. Vector2 diff = rtkPos - currentRtkPos;
  32. Vector3 pos = new Vector3(playPos.x + diff.x, posY, playPos.z + diff.y);
  33. return pos;
  34. }
  35. }