Scaling Gameobjects to N meters

185
0
03-08-2023 11:09 AM
alex_p
by
New Contributor II

This feels like a simple question, but I just want to clarify the relationship between ArcGIS distance and Unity's unit system.

Problem:

I want to scale a cylinder to N meters (for instance set its diameter to 100 meters)

In this example, I'm scaling a circle to 100 on the x and z-axis.

alex_p_1-1678301030290.png

For the circle's radius (as illustrated by the red line) I would expect a distance of 50 meters (if the unit system is using meters as default)

Using the following code:

    void Start()
    {
        var map = GameObject.Find("ArcGISMap").GetComponent<ArcGISMapComponent>();

        var center = CoordinatesUtility.UnityWorldToCoordinates(centerPoint.position, map).ToArcGISPoint();
        var right = CoordinatesUtility.UnityWorldToCoordinates(rightPoint.position, map).ToArcGISPoint();

        ArcGISAngularUnitId unitDegree = (ArcGISAngularUnitId)9102;

        var simpleDistance = ArcGISGeometryEngine.Distance(center, right);
        
        Debug.LogError($"ArcGISGeometryEngine.Distance = {simpleDistance}");
        
        var distance = ArcGISGeometryEngine.DistanceGeodetic(center, right,
            new ArcGISLinearUnit(ArcGISLinearUnitId.Meters),
            new ArcGISAngularUnit(unitDegree), ArcGISGeodeticCurveType.Geodesic).Distance;

        Debug.Log($"ArcGISGeometryEngine.DistanceGeodetic = {distance}");
    }
}

I get the following results:

ArcGISGeometryEngine.Distance = 0.000449157642059106

ArcGISGeometryEngine.DistanceGeodetic = 49.913152025082

So unless I'm mistaken it looks like the default unit system is in meters. Is this correct?

Also, why do I get such a weird value for ArcGISGeometryEngine.Distance? Is it due to the spatial reference? The origin is using 4326 and the map type is local. The base map I believe is in 3857.

0 Kudos
0 Replies