/** * Locates a point with specified coordinates. * @param x the x coordinate. * @param y the y coordinate. * @return the {@link PointLocation}. */ public synchronized PointLocation locatePoint(float x, float y) { return locatePoint((double)x,(double)y); }
private void addGhostNodes(float[] x, float[] y) { int ng = x.length; for (int ig=0; ig<ng; ++ig) { float xg = x[ig]; float yg = y[ig]; TriMesh.PointLocation pl = _mesh.locatePoint(xg,yg); if (pl.isOutside()) { TriMesh.Node n = new TriMesh.Node(xg,yg); n.data = new NodeData(); n.index = -1-ig; // ghost nodes have negative indices _mesh.addNode(n); } } }
private boolean getNaturalNabors(float x, float y) { _mesh.clearNodeMarks(); _mesh.clearTriMarks(); _nodeList.clear(); _triList.clear(); TriMesh.PointLocation pl = _mesh.locatePoint(x,y); if (pl.isOutside()) return false; addTri(x,y,pl.tri()); return true; } private void addTri(double xp, double yp, TriMesh.Tri tri) {
/** * Locates a point. */ private PointLocation locatePoint(double x, double y) { // If no tris yet, search the node list for an exact match. // Here, we use unperturbed node coordinates. if (_troot==null) { if (_nroot!=null) { Node node = _nroot; do { if (x==node.x() && y==node.y()) return new PointLocation(node); node = node._next; } while (node!=_nroot); } return new PointLocation(null,false); } // Otherwise, find a good tri in which to begin the recursive search. Node nmin = _nroot; double dmin = distanceSquared(nmin,x,y); for (Node n:_sampledNodes) { double d = distanceSquared(n,x,y); if (d<dmin) { dmin = d; nmin = n; } } Tri tri = nmin._tri; return locatePoint(tri,x,y); }
Tri triNabor = tri.triNabor(n0); if (triNabor!=null) { return locatePoint(triNabor,x,y); } else { return new PointLocation(tri,false); Tri triNabor = tri.triNabor(n1); if (triNabor!=null) { return locatePoint(triNabor,x,y); } else { return new PointLocation(tri,false); Tri triNabor = tri.triNabor(n2); if (triNabor!=null) { return locatePoint(triNabor,x,y); } else { return new PointLocation(tri,false);
PointLocation pl = locatePoint(x,y);
PointLocation pl = locatePoint(node._x,node._y);
float xg = x[ig]; float yg = y[ig]; TriMesh.PointLocation pl = _mesh.locatePoint(xg,yg); if (pl.isOutside()) { TriMesh.Node n = new TriMesh.Node(xg,yg);