/** * Computes the circumcenter of this face. * @param c array of circumcenter coordinates {xc,yc,zc}. * @return radius-squared of circumcircle. */ public double centerCircle(double[] c) { double xa = _a._x; double ya = _a._y; double za = _a._z; double xb = _b._x; double yb = _b._y; double zb = _b._z; double xc = _c._x; double yc = _c._y; double zc = _c._z; Geometry.centerCircle3D(xa,ya,za,xb,yb,zb,xc,yc,zc,c); double dx = c[0]-xc; double dy = c[1]-yc; double dz = c[2]-zc; return dx*dx+dy*dy+dz*dz; }
/** * Returns true iff node n is in circumcircle of tri abc. * Perturbation of coordinates ensures that the node is not on the circle. */ private static boolean inCircle( Node a, Node b, Node c, Node n) { return Geometry.inCircle(a._x,a._y,b._x,b._y,c._x,c._y,n._x,n._y)>0.0; }
/** * Determines if a point d is inside the circle defined by the points * a, b, and c. The latter are assumed to be in CCW order, such that * the method {@link #leftOfLine} would return a positive number. * <p> * <em>Note: this fast method may return an incorrect result.</em> * @param pa {x,y} coordinates of point a. * @param pb {x,y} coordinates of point b. * @param pc {x,y} coordinates of point c. * @param pd {x,y} coordinates of point d. * @return positive, if inside the circle; * negative, if outside the circle; * zero, otherwise. */ public static double inCircleFast( double[] pa, double[] pb, double[] pc, double[] pd) { return inCircleFast( pa[0],pa[1], pb[0],pb[1], pc[0],pc[1], pd[0],pd[1]); }
public void testLeftOfPlaneSpecial() { double[] pa = {99.50000003392293,125.85383672388726,4.712236446160304}; double[] pb = {91.50000003119546,125.85383641401195,4.712236443259705}; double[] pc = {107.5000000366504,125.85383703376256,4.712236449060903}; double[] pd = {27.50000030246409,125.8538208916998,122.28777353807229}; double ra = Geometry.leftOfPlane(pa,pb,pc,pd); double rf = Geometry.leftOfPlaneFast(pa,pb,pc,pd); assertTrue(ra==0.0); assertTrue(rf!=0.0); }
/** * Determines whether this edge is visible from the specified point. * This edge is visible if the point lies strictly right of the directed * line AB of this edge. * @param x the x coordinate of the point. * @param y the y coordinate of the point. * @return true, if visible; false, otherwise. */ public boolean isVisibleFromPoint(double x, double y) { return Geometry.leftOfLine(_a._x,_a._y,_b._x,_b._y,x,y)<0.0; }
/** * Returns true iff node n is left of oriented plane abc. * Perturbation of coordinates ensures that the node is not in the plane. */ private static boolean leftOfPlane(Node a, Node b, Node c, Node n) { return Geometry.leftOfPlane( a._x,a._y,a._z, b._x,b._y,b._z, c._x,c._y,c._z, n._x,n._y,n._z)>0.0; }
ra = Geometry.inSphere(pa,pb,pc,pd,pe); rf = Geometry.inSphereFast(pa,pb,pc,pd,pe); trace("0 inSphere: "+String.format("%26.18e",ra)); trace("0 inSphereFast: "+String.format("%26.18e",rf)); ra = Geometry.inSphere(pa,pb,pc,pd,pe); rf = Geometry.inSphereFast(pa,pb,pc,pd,pe); trace("+ inSphere: "+String.format("%26.18e",ra)); trace("+ inSphereFast: "+String.format("%26.18e",rf)); ra = Geometry.inSphere(pa,pb,pc,pd,pe); rf = Geometry.inSphereFast(pa,pb,pc,pd,pe); trace("- inSphere: "+String.format("%26.18e",ra)); trace("- inSphereFast: "+String.format("%26.18e",rf));
ra = Geometry.inCircle(pa,pb,pc,pd); rf = Geometry.inCircleFast(pa,pb,pc,pd); trace("0 inCircle: "+String.format("%26.18e",ra)); trace("0 inCircleFast: "+String.format("%26.18e",rf)); ra = Geometry.inCircle(pa,pb,pc,pd); rf = Geometry.inCircleFast(pa,pb,pc,pd); trace("+ inCircle: "+String.format("%26.18e",ra)); trace("+ inCircleFast: "+String.format("%26.18e",rf)); ra = Geometry.inCircle(pa,pb,pc,pd); rf = Geometry.inCircleFast(pa,pb,pc,pd); trace("- inCircle: "+String.format("%26.18e",ra)); trace("- inCircleFast: "+String.format("%26.18e",rf));
ra = Geometry.leftOfLine(pa,pb,pc); rf = Geometry.leftOfLineFast(pa,pb,pc); trace("0 leftOfLine: "+String.format("%26.18e",ra)); trace("0 leftOfLineFast: "+String.format("%26.18e",rf)); ra = Geometry.leftOfLine(pa,pb,pc); rf = Geometry.leftOfLineFast(pa,pb,pc); trace("+ leftOfLine: "+String.format("%26.18e",ra)); trace("+ leftOfLineFast: "+String.format("%26.18e",rf)); ra = Geometry.leftOfLine(pa,pb,pc); rf = Geometry.leftOfLineFast(pa,pb,pc); trace("- leftOfLine: "+String.format("%26.18e",ra)); trace("- leftOfLineFast: "+String.format("%26.18e",rf));
/** * Returns true iff node n is in circumsphere of tet abcd. * Perturbation of coordinates ensures that the node is not on the sphere. */ private static boolean inSphere( Node a, Node b, Node c, Node d, Node n) { return Geometry.inSphere( a._x,a._y,a._z, b._x,b._y,b._z, c._x,c._y,c._z, d._x,d._y,d._z, n._x,n._y,n._z)>0.0; }
/** * Determines if a point c is left of the line defined by the * points a and b. This is equivalent to determining whether the * points a, b, and c are in counter-clockwise (CCW) order. * <p> * <em>Note: this fast method may return an incorrect result.</em> * @param pa {x,y} coordinates of point a. * @param pb {x,y} coordinates of point b. * @param pc {x,y} coordinates of point c. * @return positive, if left of line; * negative, if right of line; * zero, otherwise. */ public static double leftOfLineFast( double[] pa, double[] pb, double[] pc) { return leftOfLineFast( pa[0],pa[1], pb[0],pb[1], pc[0],pc[1]); }
/** * Determines if a point d is left of the plane defined by the * points a, b, and c. The latter are assumed to be in CCW order, * as viewed from the right side of the plane. * <p> * <em>Note: this fast method may return an incorrect result.</em> * @param pa {x,y,z} coordinates of point a. * @param pb {x,y,z} coordinates of point b. * @param pc {x,y,z} coordinates of point c. * @param pd {x,y,z} coordinates of point d. * @return positive, if left of plane; * negative, if right of plane; * zero, otherwise. */ public static double leftOfPlaneFast( double[] pa, double[] pb, double[] pc, double[] pd) { return leftOfPlaneFast( pa[0],pa[1],pa[2], pb[0],pb[1],pb[2], pc[0],pc[1],pc[2], pd[0],pd[1],pd[2]); }
/** * Determines if a point e is inside the sphere defined by the points * a, b, c, and d. The latter are assumed to be in CCW order, such that * the method {@link #leftOfPlane} would return a positive number. * <p> * <em>Note: this fast method may return an incorrect result.</em> * @param pa {x,y,z} coordinates of point a. * @param pb {x,y,z} coordinates of point b. * @param pc {x,y,z} coordinates of point c. * @param pd {x,y,z} coordinates of point d. * @param pe {x,y,z} coordinates of point e. * @return positive, if inside the sphere; * negative, if outside the sphere; * zero, otherwise. */ public static double inSphereFast( float[] pa, float[] pb, float[] pc, float[] pd, float[] pe) { return inSphereFast( pa[0],pa[1],pa[2], pb[0],pb[1],pb[2], pc[0],pc[1],pc[2], pd[0],pd[1],pd[2], pe[0],pe[1],pe[2]); }
/** * Computes the center of the circle defined by the points a, b, and c. * The latter are assumed to be in CCW order, such that the method * {@link #leftOfLine} would return a positive number. * @param pa {x,y} coordinates of point a. * @param pb {x,y} coordinates of point b. * @param pc {x,y} coordinates of point c. * @param po array containing (x,y) coordinates of center. */ public static void centerCircle( float[] pa, float[] pb, float[] pc, float[] po) { centerCircle(pa[0],pa[1], pb[0],pb[1], pc[0],pc[1], po); }
public void testLeftOfPlaneSpecial2() { double[] pa = {111.50000056515266,125.85385176546224,4.712249324321081}; double[] pb = {123.50000062597627,125.85385229716680,4.712249325708733}; double[] pc = {105.50000053474086,125.85385224976321,4.712249323627476}; double[] pd = { 93.50000047391725,125.85385171805865,4.712249322239824}; double ra = Geometry.leftOfPlane(pa,pb,pc,pd); double rf = Geometry.leftOfPlaneFast(pa,pb,pc,pd); assertTrue(ra==0.0); assertTrue(rf!=0.0); }
/** * Returns true iff point (x,y) is left of oriented line ab. */ private static boolean leftOfLine( Node a, Node b, double x, double y) { return Geometry.leftOfLine(a._x,a._y,b._x,b._y,x,y)>0.0; }
/** * Returns true iff point (x,y,z) is left of oriented plane abc. */ private static boolean leftOfPlane( Node a, Node b, Node c, double x, double y, double z) { return Geometry.leftOfPlane( a._x,a._y,a._z, b._x,b._y,b._z, c._x,c._y,c._z, x,y,z)>0.0; }
for (nsphere=0; sw.time()<maxtime; nsphere+=niter) { for (int iter=0; iter<niter; ++iter) { Geometry.inSphere(xa,ya,za,xb,yb,zb,xc,yc,zc,xd,yd,zd,xe,ye,ze); for (nsphere=0; sw.time()<maxtime; nsphere+=niter) { for (int iter=0; iter<niter; ++iter) { Geometry.inSphereFast( xa,ya,za,xb,yb,zb,xc,yc,zc,xd,yd,zd,xe,ye,ze);
/** * Returns true iff point (x,y,z) is in circumsphere of tet abcd. * (Currently unused.) */ private static boolean inSphere( Node a, Node b, Node c, Node d, double x, double y, double z) { return Geometry.inSphere( a._x,a._y,a._z, b._x,b._y,b._z, c._x,c._y,c._z, d._x,d._y,d._z, x,y,z)>0.0; }
/** * Determines if a point c is left of the line defined by the * points a and b. This is equivalent to determining whether the * points a, b, and c are in counter-clockwise (CCW) order. * <p> * <em>Note: this fast method may return an incorrect result.</em> * @param pa {x,y} coordinates of point a. * @param pb {x,y} coordinates of point b. * @param pc {x,y} coordinates of point c. * @return positive, if left of line; * negative, if right of line; * zero, otherwise. */ public static double leftOfLineFast( float[] pa, float[] pb, float[] pc) { return leftOfLineFast( pa[0],pa[1], pb[0],pb[1], pc[0],pc[1]); }