-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
158 additions
and
49 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
import type { Matrix3x3 } from "./matrix.js"; | ||
import { ROTATION_MATRIX_e } from "./rotation.js"; | ||
import type { Vector3 } from "./vector.js"; | ||
|
||
export function lat_lon2n_E(latitude: number, longitude: number): Vector3 { | ||
export function lat_lon2n_E( | ||
latitude: number, | ||
longitude: number, | ||
R_Ee: Matrix3x3 = ROTATION_MATRIX_e, | ||
): Vector3 { | ||
const [[n00, n01, n02], [n10, n11, n12], [n20, n21, n22]] = R_Ee; | ||
|
||
const sinLat = Math.sin(latitude); | ||
const cosLat = Math.cos(latitude); | ||
const sinLon = Math.sin(longitude); | ||
const cosLon = Math.cos(longitude); | ||
|
||
return [cosLat * cosLon, cosLat * sinLon, sinLat]; | ||
const x = sinLat; | ||
const y = cosLat * sinLon; | ||
const z = -cosLat * cosLon; | ||
|
||
// flattened multiply(transpose(R_Ee), [x, y, z]) | ||
return [ | ||
n00 * x + n10 * y + n20 * z, | ||
n01 * x + n11 * y + n21 * z, | ||
n02 * x + n12 * y + n22 * z, | ||
]; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
import type { Matrix3x3 } from "./matrix.js"; | ||
import { ROTATION_MATRIX_e } from "./rotation.js"; | ||
import type { Vector3 } from "./vector.js"; | ||
|
||
export function n_E2lat_lon( | ||
n_E: Vector3, | ||
R_Ee: Matrix3x3 = ROTATION_MATRIX_e, | ||
): [latitude: number, longitude: number] { | ||
const [x, y, z] = n_E; | ||
const [[n00, n01, n02], [n10, n11, n12], [n20, n21, n22]] = R_Ee; | ||
|
||
const sinLat = z; | ||
const cosLat = Math.sqrt(y ** 2 + x ** 2); | ||
const cosLatSinLon = y; | ||
const cosLatCosLon = x; | ||
// flattened multiply(R_Ee, [x, y, z]) | ||
const rx = n00 * x + n01 * y + n02 * z; | ||
const ry = n10 * x + n11 * y + n12 * z; | ||
const rz = n20 * x + n21 * y + n22 * z; | ||
|
||
return [Math.atan2(sinLat, cosLat), Math.atan2(cosLatSinLon, cosLatCosLon)]; | ||
const sinLat = rx; | ||
const cosLat = Math.sqrt(ry ** 2 + rz ** 2); | ||
const sinLonCosLat = ry; | ||
const cosLonCosLat = -rz; | ||
|
||
return [Math.atan2(sinLat, cosLat), Math.atan2(sinLonCosLat, cosLonCosLat)]; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { Matrix3x3 } from "./matrix.js"; | ||
|
||
export const ROTATION_MATRIX_e: Matrix3x3 = [ | ||
[0, 0, 1.0], | ||
[0, 1.0, 0], | ||
[-1.0, 0, 0], | ||
]; |
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
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
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
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