Search Unity

Problem resize the images using latitude and longitude of the edges.

Discussion in 'Physics' started by LittleBoi85, Mar 13, 2019.

  1. LittleBoi85

    LittleBoi85

    Joined:
    Nov 7, 2018
    Posts:
    1
    So, in I got a task that needs me to resize the image based on the latitude and longitude of the top-left and bottom-right. My formula is right here:

    Code (CSharp):
    1.  
    2.     // Get width from the left and right lattidue
    3.     public float getHeight()
    4.     {
    5.         double radius = 6371.01;
    6.  
    7.         Quaternion q1 = Quaternion.Euler(longTopLeft, latTopLeft, 0);
    8.         Quaternion q2 = Quaternion.Euler(longTopLeft, latBotRight, 0);
    9.         print(Quaternion.Angle(q1, q2));
    10.         double theta = Quaternion.Angle(q1, q2) * Mathf.Deg2Rad;
    11.         return (float)(radius * theta);
    12.     }
    13.  
    14.     // Get width from the left and right longitude.
    15.     public float getWidth()
    16.     {
    17.         double radius = 6371.01;
    18.  
    19.         Quaternion q1 = Quaternion.Euler(longTopLeft, latTopLeft, 0);
    20.         Quaternion q2 = Quaternion.Euler(longBotRight, latTopLeft, 0);
    21.         print(Quaternion.Angle(q1, q2));
    22.         double theta = Quaternion.Angle(q1, q2) * Mathf.Deg2Rad;
    23.         return (float)(radius * theta);
    24.     }
    25.  
    The problem is that the images will always be too small or too large, is there anything that I could adjust to make it work?