/* Last edited on 2025-01-01 15:10:17 by stolfi */ /* ---------------------------------------------------------------------- */ /* pst_geom.{h,c} */ typedef struct pst_geom_sphere_t /* Parameters of a sphere's image: */ { r2_t ctr; /* Center (pixels). */ double rad; /* Radius (length of shortest semidiameter). */ r2_t str; /* Stretch vector (longest semidiameter minus {rad}). */ } pst_geom_sphere_t; /* A {pst_geom_sphere_t} describes the perspective projection of a spherical object. It is assumed that the sphere radius is small compared to the camera-to-object distance, so that the perspective projection is well approximated by a parallel oblique projection. This assumption should be harmless for a small sphere taken at typical camera geometries. */ ellipse_crs_t *pst_geom_sphere_new(void); /* Allocates a new {ellipse_crs_t} record. All parameters are set to zero. Fails if no mem available. */ ellipse_crs_t *pst_geom_sphere_new(void) { ellipse_crs_t *geo = (ellipse_crs_t *)notnull(malloc(sizeof(ellipse_crs_t)), "no mem"); geo->ctr = (r2_t){{ 0, 0 }}; geo->rad = 0; geo->str = (r2_t){{ 0, 0 }}; return geo; }