Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize the algorithm of Extent conversion TE viewing position of two-dimensional Map by C #

Shulou Source: shulou.com Published: 2022-06-01 03:37:31 10月05日 Update

This article will explain in detail how to realize the Extent conversion TE viewing position algorithm of two-dimensional map in C#. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

In the development of the system, we sometimes encounter the function development of two-dimensional linkage, that is, when the two-dimensional map moves, the three-dimensional movement moves with the movement, the three-dimensional map moves, and the two-dimensional map also changes.

The perspective of two-dimensional map is an upright viewing direction from top to bottom, and three-dimensional map can constantly change the viewing direction, so, in the process of linkage, when two-dimensional controls three-dimensional, the three-dimensional perspective can only maintain an upright downward direction in order to be consistent with two-dimensional.

In the process of moving a two-dimensional map, the four-to-four coordinates of the map, namely XMax,XMin,YMax,YMin, can be obtained. According to this range, a rough range can be calculated in TE for map positioning.

The specific code implementation is as follows (C #):

/ / XMax,XMin,YMax,YMin is 4 coordinates

Double pcenterX = (XMax+XMin) / 2

Double pcenterY = (YMax + YMin) / 2

/ / calculate the horizontal distance of the map

Double pdistance = SGWorld.CoordServices.GetDistance (XMax, YMax, XMin,YMax)

/ / calculate the vertical viewing height according to the horizontal viewing distance and the viewing range of the TE

Double pviewHeight = pdistance / 2 / Math.Tan (Math.PI * SGWorld.Navigate.FieldOfView / 360)

/ / calculate the viewing position according to the center point and viewing height

Var newPos = SGWorld.Creator.CreatePosition (pcenterX, pcenterY, pviewHeight, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, 0,-89, 0, 0)

/ / navigate to the new location

SGWorld61.Navigate.SetPosition (newPos)

On "how to achieve two-dimensional map Extent TE viewing position algorithm" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Tags: Map 2D 3D Mobile location Category Direction Article range algorithm coordinates more horizontal Angle of View process height change Positioning Development good Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS Microsoft Shulou Technology Shulou Information