Created
November 16, 2023 03:10
-
-
Save inoook/922cfc85befc63533055cedd6f930e56 to your computer and use it in GitHub Desktop.
Equirectangular座標から球面の3D座標に変換する関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Equirectangular座標から球面の3D座標に変換する関数 | |
/// </summary> | |
/// <param name="lon">経度(0から1の範囲)</param> | |
/// <param name="lat">緯度(0から1の範囲)</param> | |
/// <returns></returns> | |
Vector3 EquirectangularToSphereCoordinates(float lon, float lat) | |
{ | |
float u = lon; | |
float v = lat; | |
// Equirectangular座標から球面の3D座標に変換 | |
Vector3 sphereCoord = new Vector3( | |
-Mathf.Cos(u * 2 * Mathf.PI) * Mathf.Sin(v * Mathf.PI), | |
-Mathf.Cos(v * Mathf.PI), | |
Mathf.Sin(u * 2 * Mathf.PI) * Mathf.Sin(v * Mathf.PI) | |
); | |
return sphereCoord; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment