This will attempt to find what the last point is and returns that
position. If the location is circular this will return the total length
of the location and does not mean the maximum point on the Sequence
we may find the locations on
764544
public static Point detectEnd(List<Location> subLocations, boolean isCircular) {
		int end = 0;
		Point lastPoint = null;
		if(isCircular) {
			for (Location sub : subLocations) {
				lastPoint = sub.getEnd();
				end += lastPoint.getPosition();
			}
		}
		else {
			lastPoint = subLocations.get(subLocations.size()-1).getEnd();
			end = lastPoint.getPosition();
		}
		return new SimplePoint(end, lastPoint.isUnknown(), lastPoint.isUncertain());
	}
1128933
protected int circularDistance( int start , int end ) {
		if( end >= start )
			return end-start;
		else
			return N-start+end;
	}
442479
def nearestPoint(self, pos):
        
        # lookup subpaths
        for x, y, path in self._subpaths:
            if path.contains(pos):
                return (x, y)
        
        return (None, None)
944943
public void getClosestPoint(Vector2f point, Vector2f result) {
		loc.set(point);
		loc.sub(start);

		float projDistance = vec.dot(loc);

		projDistance /= vec.lengthSquared();

		if (projDistance < 0) {
			result.set(start);
			return;
		}
		if (projDistance > 1) {
			result.set(end);
			return;
		}

		result.x = start.getX() + projDistance * vec.getX();
		result.y = start.getY() + projDistance * vec.getY();
	}
1072572
private void calibrateLast() throws JspTagException {
        /*
         * the current round is the last one if (a) there are no remaining
         * elements, or (b) the next one is beyond the 'end'.
         */
        last = !hasNext() || atEnd() ||
                (end != -1 && (begin + index + step > end));
    }
322608
function getNearestDataPoint(mouseX) {
            let points = dataByDate.filter(({date}) => Math.abs(xScale(date) - mouseX) <= epsilon);

            if (points.length) {
                return points[0];
            }
        }
909796
def getBottomRight(self):
        
        return Location(self.x+self.w, self.y+self.h)
488643
public function getLastPoint()
    {
        if (empty($this->points)) {
            return null;
        }
        return $this->points[count($this->points) - 1];
    }
206979
Point determineClosestCentre(Point p, Point centreA, Point centreB){
		
		//loop counter variable
		int l;	

		//stores the distance between p and centreA
		double distanceA = 0.0;

		for(l=0;l<p.dimension;l++){
			//centroid coordinate of the point
			double centroidCoordinatePoint;
			if(p.weight != 0.0){
				centroidCoordinatePoint = p.coordinates[l] / p.weight;
			} else {
				centroidCoordinatePoint = p.coordinates[l];
			}
			//centroid coordinate of the centre
			double centroidCoordinateCentre;
			if(centreA.weight != 0.0){
				centroidCoordinateCentre = centreA.coordinates[l] / centreA.weight;
			} else {
				centroidCoordinateCentre = centreA.coordinates[l];
			}

			distanceA += (centroidCoordinatePoint-centroidCoordinateCentre) * 
					(centroidCoordinatePoint-centroidCoordinateCentre) ;
		}

		//stores the distance between p and centreB
		double distanceB = 0.0;

		for(l=0;l<p.dimension;l++){
			//centroid coordinate of the point
			double centroidCoordinatePoint;
			if(p.weight != 0.0){
				centroidCoordinatePoint = p.coordinates[l] / p.weight;
			} else {
				centroidCoordinatePoint = p.coordinates[l];
			}
			//centroid coordinate of the centre
			double centroidCoordinateCentre;
			if(centreB.weight != 0.0){
				centroidCoordinateCentre = centreB.coordinates[l] / centreB.weight;
			} else {
				centroidCoordinateCentre = centreB.coordinates[l];
			}

			distanceB += (centroidCoordinatePoint-centroidCoordinateCentre) * 
					(centroidCoordinatePoint-centroidCoordinateCentre) ;
		}

		//return the nearest centre
		if(distanceA < distanceB){
			return centreA;
		} else {
			return centreB;
		}
	}
1351087
function findClosestPointIndexWithinRadius(points, x, y, radiusThreshold) {
    let closestIdx;
    let closestDist = Number.MAX_VALUE;
    points.forEach((d, idx) => {
      let distSqrd = Math.pow(d.x - x, 2) + Math.pow(d.y - y, 2); // changeto: (d.x - x)**2 + (d.y - y)**2;
      if (distSqrd < closestDist && distSqrd < radiusThreshold) {
        closestIdx = idx;
        closestDist = distSqrd;
      }
    });
    return closestIdx;
  }
226816
def next_pos(self):
        
        result = None
        if self._index <= len(self._steps):
            result = self._steps[self._index]
            self._index += 1
        return result
1357941
function(curCoord, finalCoord) {
        this.logger.log("getNextX: " + curCoord + ", " + finalCoord);
        var t = this.thumb,
            thresh,
            tmp = [],
            nextCoord = null;

        if (curCoord[0] > finalCoord[0]) {
            thresh = t.tickSize - this.thumbCenterPoint.x;
            tmp = t.getTargetCoord( curCoord[0] - thresh, curCoord[1] );
            nextCoord = [tmp.x, tmp.y];
        } else if (curCoord[0] < finalCoord[0]) {
            thresh = t.tickSize + this.thumbCenterPoint.x;
            tmp = t.getTargetCoord( curCoord[0] + thresh, curCoord[1] );
            nextCoord = [tmp.x, tmp.y];
        } else {
            // equal, do nothing
        }

        return nextCoord;
    }
718975
public Long getRelativePosition(Long position) {
		long relativePosition = 0L;
		for (Location location : locations) {
			if (location instanceof RemoteLocation) {
				relativePosition += location.getLength();
			} else {
				if (position < location.getBeginPosition()
						|| position > location.getEndPosition()) {
					relativePosition += location.getLength();
				} else {
					if (location.isComplement()) {
						relativePosition += (location.getEndPosition()
								- position + 1);
					} else {
						relativePosition += (position
								- location.getBeginPosition() + 1);
					}
					if (isComplement()) {
						relativePosition = getLength() - relativePosition + 1;
					}
					return relativePosition;
				}
			}
		}
		return null;
	}
1290350
def get_position(self):
        
        with self._lock:
            return self.x, self.y, self.angle
1052806
@SuppressWarnings("fallthrough")
    private boolean findSection(int offset, Position pos)
    {
        int i = offset, len = rawBytes.length;
        int last = offset;
        int next;
        boolean allBlank = true;

        pos.endOfFirstLine = -1;

        while (i < len) {
            byte b = rawBytes[i];
            switch(b) {
            case '\r':
                if (pos.endOfFirstLine == -1)
                    pos.endOfFirstLine = i-1;
                if ((i < len) &&  (rawBytes[i+1] == '\n'))
                    i++;
                /* fall through */
            case '\n':
                if (pos.endOfFirstLine == -1)
                    pos.endOfFirstLine = i-1;
                if (allBlank || (i == len-1)) {
                    if (i == len-1)
                        pos.endOfSection = i;
                    else
                        pos.endOfSection = last;
                    pos.startOfNext = i+1;
                    return true;
                }
                else {
                    // start of a new line
                    last = i;
                    allBlank = true;
                }
                break;
            default:
                allBlank = false;
                break;
            }
            i++;
        }
        return false;
    }
1275692
function ( t ) {

		var d = t * this.getLength();
		var curveLengths = this.getCurveLengths();
		var i = 0;

		// To think about boundaries points.

		while ( i < curveLengths.length ) {

			if ( curveLengths[ i ] >= d ) {

				var diff = curveLengths[ i ] - d;
				var curve = this.curves[ i ];

				var u = 1 - diff / curve.getLength();

				return curve.getPointAt( u );

			}

			i ++;

		}

		return null;

		// loop where sum != 0, sum > d , sum+1 <d

	}
834048
public long findPosition(long nOccurrence) {
		updateCount();
		if (nOccurrence <= 0) {
			return RankedBitVector.NOT_FOUND;
		}
		int findPos = (int) (nOccurrence / this.blockSize);
		if (findPos < this.positionArray.length) {
			long pos0 = this.positionArray[findPos];
			long leftOccurrences = nOccurrence - (findPos * this.blockSize);
			if (leftOccurrences == 0) {
				return pos0;
			}
			for (long index = pos0 + 1; index < this.bitVector.size(); index++) {
				if (this.bitVector.getBit(index) == this.bit) {
					leftOccurrences--;
				}
				if (leftOccurrences == 0) {
					return index;
				}
			}
		}
		return RankedBitVector.NOT_FOUND;
	}