/** * 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); }
/** * 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( double[] pa, double[] pb, double[] pc, double[] po) { centerCircle(pa[0],pa[1], pb[0],pb[1], pc[0],pc[1], po); }
/** * Computes the circumcenter of this tri. * @param c array of circumcenter coordinates {xc,yc}. * @return radius-squared of circumcircle. */ public double centerCircle(double[] c) { if (hasCenter()) { c[0] = _xc; c[1] = _yc; } else { double x0 = _n0._x; double y0 = _n0._y; double x1 = _n1._x; double y1 = _n1._y; double x2 = _n2._x; double y2 = _n2._y; Geometry.centerCircle(x0,y0,x1,y1,x2,y2,c); setCenter(c[0],c[1]); } double dx = _xc-_n2._x; double dy = _yc-_n2._y; return dx*dx+dy*dy; }
private void addEdge( double xp, double yp, double xr, double yr, TriMesh.Node na, TriMesh.Node nb) { double xa = na.xp(), ya = na.yp(); double xb = nb.xp(), yb = nb.yp(); Geometry.centerCircle(xp,yp,xa,ya,xb,yb,_xy); double xf = _xy[0]-xp, yf = _xy[1]-yp; _edgeList.add(na,nb,xf,yf,xr,yr); }
public double accumulateAreas( double xp, double yp, TriMesh mesh, TriMesh.NodeList nodeList, TriMesh.TriList triList) { clear(); int ntri = triList.ntri(); TriMesh.Tri[] tris = triList.tris(); for (int itri=0; itri<ntri; ++itri) { TriMesh.Tri tri = tris[itri]; TriMesh.Node na = tri.nodeA(); TriMesh.Node nb = tri.nodeB(); TriMesh.Node nc = tri.nodeC(); double xa = na.xp(), ya = na.yp(); double xb = nb.xp(), yb = nb.yp(); double xc = nc.xp(), yc = nc.yp(); Geometry.centerCircle(xp,yp,xb,yb,xc,yc,_ca); Geometry.centerCircle(xp,yp,xc,yc,xa,ya,_cb); Geometry.centerCircle(xp,yp,xa,ya,xb,yb,_cc); Geometry.centerCircle(xa,ya,xb,yb,xc,yc,_ct); double aa = area(_cb,_cc,_ct); double ab = area(_cc,_ca,_ct); double ac = area(_ca,_cb,_ct); accumulate(na,aa); accumulate(nb,ab); accumulate(nc,ac); } return sum(); } private double[] _ca = new double[2]; // circumcenter of fake tri pbc