cds-astro / cds-healpix-java

The CDS HEALPix library in Java
BSD 3-Clause "New" or "Revised" License
9 stars 9 forks source link

AssertionError in vertex calculation #16

Closed mbtaylor closed 2 years ago

mbtaylor commented 2 years ago

The following program throws an AssertionError (if run with -enableassertions) in the vertex invocation:

import cds.healpix.CompassPoint;
import cds.healpix.Healpix;
import cds.healpix.VerticesAndPathComputer;

public class Vert {
    public static void main( String[] args ) {
        int order = 4;
        int hash = 87;
        CompassPoint.Cardinal cardinal = CompassPoint.Cardinal.N;
        VerticesAndPathComputer vc = Healpix.getNestedFast(order);
        double[] lonlat = vc.vertex(hash, cardinal);
        System.out.println(lonlat[0] + ", " + lonlat[1]);
    }
}
mbtaylor commented 2 years ago

Further: if called with order = 1, hash = 3 and assertions disabled, then lonlat[0] is NaN. Using getNested instead of getNestedFast seems to be OK.

fxpineau commented 2 years ago

Indeed, HealpixNestedFast.vertex was bugged. Thank you for the report. I have added a test to cross-check HealpixNested.vertex with HealpixNestedFast.vertex.