Skip to content

Commit

Permalink
region: Use astNormPoints to avoid longitude jumps in region meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
dsberry committed Oct 28, 2021
1 parent 16b771a commit 1ba18e1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ast.news
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ system. The most common usage will be to modify vectors of sky position
in such a way as to avoid sudden jumps of 360 degrees in longitude within
groups of points that span the longitude origin.

- The mesh of points returned by astGetRegionMesh and astShowMesh are now
normalised to avoid discontinuities in celestial longitude. This uses the
new astNormPoints methid described in the previous item.

- A bug has been fixed in the KeyMap class that caused astMapGet1<X>
functions to return a vector length of 1 for KeyMap entries with an
undefined value. A vector length of zero is now returned in such cases.
Expand Down
4 changes: 2 additions & 2 deletions src/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -8204,15 +8204,15 @@ static AstPointSet *NormalPoints( AstFrame *this, AstPointSet *in, int contig,
for ( point = 0; point < npoint; point++ ) {

/* Copy the axis values at the current point into the buffer. */
for ( coord = 0; coord < ncoord_in; coord++ ) {
for ( coord = 0; coord < naxes; coord++ ) {
buf[ coord ] = ptr_in[ coord ][ point ];
}

/* Normalise the values stored in the buffer. */
astNorm( this, buf );

/* Copy the normalised values to the output pointset. */
for ( coord = 0; coord < ncoord_out; coord++ ) {
for ( coord = 0; coord < naxes; coord++ ) {
ptr_out[ coord ][ point ] = buf[ coord ];
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/region.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ f - AST_SHOWMESH: Display a mesh of points on the surface of a Region
* is cleared in the copy. This means that if a component Region within
* a CmpRegion is copied, a dump of the resulting copy will include the
* FrameSet.
* 28-OCT-2021 (DSB):
* Modified astGetRegionMesh so that meshes for SkyFrame regions that cross
* zero longitude do not include jumps of 2.PI in logitude.
*class--
* Implementation Notes:
Expand Down Expand Up @@ -9317,12 +9320,17 @@ f The global status.
* original to new coordinate system is non-linear, the shape within
* the new coordinate system may be distorted, and so may not match
* that implied by the name of the Region subclass (Circle, Box, etc).
* - If the Region defines an area within a SkyFrame that traverses
* zero longitude, the returned positions will be normalised to avoid
* jumps of 2.PI radians in longitude (i.e. it will include longitude
* values less than zero or greater than 2.PI).
*--
*/

/* Local Variables: */
AstPointSet *pset; /* PointSet holding mesh/grid axis values */
AstPointSet *temp; /* PointSet holding normalised mesh/grid axis values */
double **ptr; /* Pointer to mesh/grid axes values */
double *p; /* Pointer to next input axis value */
double *q; /* Pointer to next output axis value */
Expand Down Expand Up @@ -9351,12 +9359,18 @@ f The global status.
} else {
pset = astRegBaseGrid( this );
}

} else {
if( surface ) {
pset = astRegMesh( this );
} else {
pset = astRegGrid( this );
}

/* Normalise the points to avoid discontinuities (e.g. at zero longitude). */
temp = astNormalPoints( this, pset, 1, NULL );
pset = astAnnul( pset );
pset = temp;
}

/* Return the number of points in the mesh or grid. */
Expand Down Expand Up @@ -10947,6 +10961,7 @@ f The global status.

/* Local Variables: */
AstPointSet *ps; /* PointSet holding mesh */
AstPointSet *temp; /* PointSet holding normalised mesh */
char *buffer = NULL; /* Buffer for line output text */
char buf[ 40 ]; /* Buffer for floating poitn value */
double **ptr; /* Pointers to the mesh data */
Expand All @@ -10963,6 +10978,11 @@ f The global status.
ps = astRegMesh( this );
if( ps ) {

/* Normalise it to avoid discontinuities in longitude etc */
temp = astNormalPoints( this, ps, 1, NULL );
ps = astAnnul( ps );
ps = temp;

/* Get the number of axis values per position, and the number of positions. */
nax = astGetNcoord( ps );
np = astGetNpoint( ps );
Expand Down
4 changes: 4 additions & 0 deletions sun_master.tex
Original file line number Diff line number Diff line change
Expand Up @@ -22472,6 +22472,10 @@ \subsection{\xlabel{changes}\xlabel{list_of_most_recent_changes}Changes
in such a way as to avoid sudden jumps of 360 degrees in longitude within
groups of points that span the longitude origin.

- The mesh of points returned by astGetRegionMesh and astShowMesh are now
normalised to avoid discontinuities in celestial longitude. This uses the
new astNormPoints methid described in the previous item.

\item A bug has been fixed in the KeyMap class that caused astMapGet1<X>
functions to return a vector length of 1 for KeyMap entries with an
undefined value. A vector length of zero is now returned in such cases.
Expand Down

0 comments on commit 1ba18e1

Please sign in to comment.