편집 : 행렬을 회전 할 때 여전히 경도 계산에 어려움을 겪고 있습니다.수학 : 모델 행렬에서 x0, y0, z1의 경도 및 위도
아래 경도 공식은 행성 북극이 멋지게 똑바로 올라가는 한 훌륭합니다. ATAN2 기능에서 사용되는 Forward 축을 멋지게 회전시킬 수 있습니다.
그러나 북쪽이 멀리 떨어질수록 ATAN2 기능에서 오류가 발생합니다. 이는 내 forwardX 및 forwardZ가 Y 축 구성 요소의 영향을 받기 때문에 발생합니다.
행성의 북극이 수평 (예 : 3시 방향)하고 동쪽으로 행성이 회전 할 때 (ATL2 공식은 앞으로 X를 사용하기 때문에 내 경도에서 변화가 없음)
Google 어스가 이것을 알아 냈으므로 방법이 있어야합니다.
어떻게 든 3 축을 모두 고려해야합니다.
저는 Android Studio Java OpenGL 2.0에서 작업하고 있습니다. 나에게 어떤 식으로 말해 그
// tanslate and scale the model matrix
Matrix.setIdentityM(SolarSystemObjects.mPlanetModelMatrix, 0);
Matrix.translateM(SolarSystemObjects.mPlanetModelMatrix, 0, objectX, objectY, objectZ);
Matrix.scaleM(SolarSystemObjects.mPlanetModelMatrix, 0, planetScale, planetScale, planetScaleZ);
// Set a matrix that contains the current rotation.
Matrix.setIdentityM(mCurrentRotation, 0);
Matrix.rotateM(mCurrentRotation, 0, planetRotationX, 0f, 1f, 0f);
Matrix.rotateM(mCurrentRotation, 0, planetRotationY, 1f, 0f, 0f);
// rotation to the result.
Matrix.multiplyMM(mTemporaryMatrix, 0, mCurrentRotation, 0, mAccumulatedRotation, 0);
System.arraycopy(mTemporaryMatrix, 0, mAccumulatedRotation, 0, 16);
// Rotate the planet taking the overall rotation into account.
Matrix.multiplyMM(mTemporaryMatrix, 0, SolarSystemObjects.mPlanetModelMatrix, 0, mAccumulatedRotation, 0);
System.arraycopy(mTemporaryMatrix, 0, SolarSystemObjects.mPlanetModelMatrix, 0, 16);
mAccumulatedRotaion
매트릭스가 오른쪽, 위, 앞으로 벡터를 포함
나는 나는 다음과 같은 코드를 사용하여 좋은 작품 터치를 사용하여 주위를 회전 할 수있는 영역 (행성)가 구가 회전합니다. 그래서 나는 북쪽이 나의 행성에 어떤 방향인지를 안다.
는 지금은
위도와 경도 내 행성의 북극에 참조 할 필요가 (화면의 전면 및 센터) 경도와 벡터의 위도 x=0f, y=0f, z=1.0f
에서를 계산하는 수학 도움이 필요 . (모든 방향을 가리킬 수있다)
나는 Up Vector와 Right Vector를 사용하여 이것을 해결할 수 있어야한다고 확신한다.
위로 (북쪽)가 x=0.3f,y=0.6f,z=-0.45f
인 경우 내 x=0f, y=0f, z=1.0f
(남반구) 벡터가 남반구에 있음을 알 수 있습니다.
하지만 수학을 어디에서 시작해야할지 모르겠다. Long/Lat에서 XYZ로 변환하는이 포럼의 예제를 찾았지만 문제점을 해결하기 위해 수학을 뒤집을 수는 없습니다.
나는 다음과 같은 코드를 사용하여 2 개 차원 벡터 사이의 각도를 측정하여 위도에 대한 해결책을 발견 :
float top = (northX * 0f) + (northY * 0f) + (northZ * 1f);
float bottom = (float)(Math.sqrt((northX * northX) + (northY * northY) + (northZ * northZ)) * Math.sqrt((0f * 0f) + (0f * 0f) + (1f * 1f)));
float latitude = 90f - (float)Math.toDegrees(Math.acos(top/bottom));
그러나,이 경도 작동하지 않습니다 (완전 작동).
편집
: 는 경도를 위해 나는 다음과 같은 코드를 사용했다 : (여전히 제대로 작동하지)float longitude = (float)Math.toDegrees(Math.atan2(forwardX, forwardZ));
북극 똑바로 때 작동하지만, 수직에서 북극 드리프트로 실패합니다.
나를 도와 주실 시간이있는 수학 전문가에게 미리 감사드립니다!
[XYZ에 LatLon (https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#From_geodetic_to_ECEF_coordinates) 및 역방향 : XYZ에 LatLon (https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#The_application_of_Ferrari 's_solution). 페라리의 솔루션은 꽤 잘 작동합니다. – QBrute