Fix: correct ICRS camera orientation

This commit is contained in:
wyj committed 2026-08-31 00:13:37 -04:00
1 parent e8deb1ff19
commit b2ac642de7
7 files changed
+47 -27

No files matched your search

+8 -6
View File
@@ -91,9 +91,11 @@ int catalog_load_csv(StarCatalog *catalog, const char *path)
const double lat = latitude * PI / 180.0;
const double cos_lat = cos(lat);
Star *star = &catalog->stars[catalog->count++];
/* Standard right-handed ICRS Cartesian axes: X is (RA, Dec) =
* (0, 0), Y is (90, 0), and Z is the north celestial pole. */
star->direction[0] = cos_lat * cos(lon);
star->direction[1] = sin(lat);
star->direction[2] = cos_lat * sin(lon);
star->direction[1] = cos_lat * sin(lon);
star->direction[2] = sin(lat);
star->temperature_K = temperature;
star->amplitude = amplitude;
}
@@ -170,10 +172,10 @@ int catalog_load_all_sky(StarCatalog *catalog, const char *directory)
static void lon_lat_from_direction(const double direction[3], double *longitude,
double *latitude)
{
*longitude = atan2(direction[2], direction[0]) * 180.0 / PI;
*longitude = atan2(direction[1], direction[0]) * 180.0 / PI;
if (*longitude < 0.0)
*longitude += 360.0;
*latitude = asin(fmax(-1.0, fmin(1.0, direction[1]))) * 180.0 / PI;
*latitude = asin(fmax(-1.0, fmin(1.0, direction[2]))) * 180.0 / PI;
}
static double dot(const double a[3], const double b[3])
@@ -195,8 +197,8 @@ static void direction_from_lon_lat(double longitude, double latitude,
const double lat = latitude * PI / 180.0;
const double cos_lat = cos(lat);
direction[0] = cos_lat * cos(lon);
direction[1] = sin(lat);
direction[2] = cos_lat * sin(lon);
direction[1] = cos_lat * sin(lon);
direction[2] = sin(lat);
}
/* The minimum of a plane dot-product over a longitude/latitude rectangle is
+4 -2
View File
@@ -183,8 +183,10 @@ static int parse_args(int argc, char **argv, Settings *s,
.verbose = 1,
#endif
.horizontal_fov_deg = 30.0,
.look_ra_deg = 270.0,
.look_dec_deg = 0.0,
/* Preserve the legacy -Z view after switching to standard
* right-handed ICRS Cartesian axes. */
.look_ra_deg = 90.0,
.look_dec_deg = -90.0,
.exposure = 1e-3,
.max_magnification = INFINITY,
.max_cache_psf_flux = 1.0,
+12 -10
View File
@@ -19,9 +19,11 @@ ObserverState observer_fixed_at_origin_look_at(double ra_deg, double dec_deg) {
const double dec = dec_deg * pi / 180.0;
const double cos_ra = cos(ra), sin_ra = sin(ra);
const double cos_dec = cos(dec), sin_dec = sin(dec);
const double forward[3] = {cos_dec * cos_ra, sin_dec, cos_dec * sin_ra};
const double up[3] = {-sin_dec * cos_ra, cos_dec, -sin_dec * sin_ra};
const double right[3] = {-sin_ra, 0.0, cos_ra};
const double forward[3] = {cos_dec * cos_ra, cos_dec * sin_ra, sin_dec};
const double up[3] = {-sin_dec * cos_ra, -sin_dec * sin_ra, cos_dec};
/* forward cross celestial north is celestial west: with north up, image
* right is decreasing RA. */
const double right[3] = {sin_ra, -cos_ra, 0.0};
return (ObserverState){.coordinate_time = 0.0,
.coordinate_position = {0.0, 0.0, 0.0},
.tetrad = {{1.0, 0.0, 0.0, 0.0},
@@ -41,14 +43,14 @@ static int schwarzschild_look_direction(double ra_deg, double dec_deg,
const double cos_ra = cos(ra), sin_ra = sin(ra);
const double cos_dec = cos(dec), sin_dec = sin(dec);
direction[0] = cos_dec * cos_ra;
direction[1] = sin_dec;
direction[2] = cos_dec * sin_ra;
direction[1] = cos_dec * sin_ra;
direction[2] = sin_dec;
up[0] = -sin_dec * cos_ra;
up[1] = cos_dec;
up[2] = -sin_dec * sin_ra;
right[0] = -sin_ra;
right[1] = 0.0;
right[2] = cos_ra;
up[1] = -sin_dec * sin_ra;
up[2] = cos_dec;
right[0] = sin_ra;
right[1] = -cos_ra;
right[2] = 0.0;
return 0;
}
+3 -2
View File
@@ -9,8 +9,9 @@ typedef struct {
} ObserverState;
ObserverState observer_fixed_at_origin(void);
/* Point the fixed inertial observer at an ICRS-style RA/Dec direction.
* The local spatial axes remain (forward, celestial north, increasing RA). */
/* Point the fixed inertial observer at a standard right-handed ICRS RA/Dec
* direction. The local spatial axes are (forward, celestial north,
* celestial west), so a north-up image has decreasing RA to the right. */
ObserverState observer_fixed_at_origin_look_at(double ra_deg, double dec_deg);
/* Static camera at Cartesian Kerr--Schild position -radius * look_direction,
* directed toward the Schwarzschild black hole at the origin. look_direction