/** * 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; }
ra = Geometry.leftOfLine(pa,pb,pc); rf = Geometry.leftOfLineFast(pa,pb,pc); trace("0 leftOfLine: "+String.format("%26.18e",ra)); ra = Geometry.leftOfLine(pa,pb,pc); rf = Geometry.leftOfLineFast(pa,pb,pc); trace("+ leftOfLine: "+String.format("%26.18e",ra)); ra = Geometry.leftOfLine(pa,pb,pc); rf = Geometry.leftOfLineFast(pa,pb,pc); trace("- leftOfLine: "+String.format("%26.18e",ra));
/** * 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 line ab. * Perturbation of coordinates ensures that the node is not in the line. */ private static boolean leftOfLine(Node a, Node b, Node n) { return Geometry.leftOfLine(a._x,a._y,b._x,b._y,n._x,n._y)>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. * @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 leftOfLine( float[] pa, float[] pb, float[] pc) { return leftOfLine( pa[0],pa[1], pb[0],pb[1], pc[0],pc[1]); }
/** * 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. * @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 leftOfLine( double[] pa, double[] pb, double[] pc) { return leftOfLine( pa[0],pa[1], pb[0],pb[1], pc[0],pc[1]); }
/** * 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 xa x-coordinate of point a. * @param ya y-coordinate of point a. * @param xb x-coordinate of point b. * @param yb y-coordinate of point b. * @param xc x-coordinate of point c. * @param yc y-coordinate of point c. * @param po array containing (x,y) coordinates of center. */ public static void centerCircle( float xa, float ya, float xb, float yb, float xc, float yc, float[] po) { double acx = xa - xc; double bcx = xb - xc; double acy = ya - yc; double bcy = yb - yc; double acs = acx*acx+acy*acy; double bcs = bcx*bcx+bcy*bcy; double scale = 0.5/leftOfLine(xa,ya,xb,yb,xc,yc); po[0] = (float)(xc+scale*(acs*bcy-bcs*acy)); po[1] = (float)(yc+scale*(bcs*acx-acs*bcx)); }
/** * 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 xa x-coordinate of point a. * @param ya y-coordinate of point a. * @param xb x-coordinate of point b. * @param yb y-coordinate of point b. * @param xc x-coordinate of point c. * @param yc y-coordinate of point c. * @param po array containing (x,y) coordinates of center. */ public static void centerCircle( double xa, double ya, double xb, double yb, double xc, double yc, double[] po) { double acx = xa - xc; double bcx = xb - xc; double acy = ya - yc; double bcy = yb - yc; double acs = acx*acx+acy*acy; double bcs = bcx*bcx+bcy*bcy; double scale = 0.5/leftOfLine(xa,ya,xb,yb,xc,yc); po[0] = xc+scale*(acs*bcy-bcs*acy); po[1] = yc+scale*(bcs*acx-acs*bcx); }
double acs = acx*acx+acy*acy+acz*acz; double bcs = bcx*bcx+bcy*bcy+bcz*bcz; double abx = leftOfLine(ya,za,yb,zb,yc,zc); double aby = leftOfLine(za,xa,zb,xb,zc,xc); double abz = leftOfLine(xa,ya,xb,yb,xc,yc); double scale = 0.5/(abx*abx+aby*aby+abz*abz); po[0] = xc+scale*((acs*bcy-bcs*acy)*abz-(acs*bcz-bcs*acz)*aby);
/** * Creates the first tri in the mesh from three nodes. */ private void createFirstTri() { Check.state(_nnode==3,"exactly three nodes available for first tri"); Node n0 = _nroot; Node n1 = n0._next; Node n2 = n1._next; double orient = Geometry.leftOfLine( n0._x,n0._y, n1._x,n1._y, n2._x,n2._y); Check.state(orient!=0,"three nodes for first tri are not co-linear"); if (orient>0.0) { makeTri(n0,n1,n2); } else { makeTri(n0,n2,n1); } }
double d0 = Geometry.leftOfLine(x2,y2,x1,y1,x,y); if (d0>0.0) { Tri triNabor = tri.triNabor(n0); double d1 = Geometry.leftOfLine(x0,y0,x2,y2,x,y); if (d1>0.0) { Tri triNabor = tri.triNabor(n1); double d2 = Geometry.leftOfLine(x1,y1,x0,y0,x,y); if (d2>0.0) { Tri triNabor = tri.triNabor(n2);