/** * Returns the dot-product of the specified <code>Position</code>s * <p/> * * @param p0 first operand * @param p1 second operand * @return the dot-product of p0 and p1. */ public static <P extends C2D> double dot(P p0, P p1) { if (p0.isEmpty() || p1.isEmpty()) return Double.NaN; return p0.getX() * p1.getX() + p0.getY() * p1.getY(); }
@Override public void visit(Point<P> point) { // Note that this is also used when visiting MultiPoints P pos = point.getPosition(); double dts = Math.hypot(pos.getX() - searchPosition.getX(), pos.getY() - searchPosition.getY()); if (dts <= distToSearchPoint) { mValue = point.getPosition().getM(); distToSearchPoint = dts; } }
/** * Applies the perp dot-operation on the specified <code>Position</code>s * <p/> * <p>The perp dot operation on vectors <code>P</code>, <code>Q</code> is defined as * <code>dot(perp(P),Q)</code>.</p> * <p/> * <p>This operation will be performed in 2D only.</p> * * @param p0 first operand * @param p1 second operand * @return the Perp dot of p0 and p1. */ public static <P extends C2D> double perpDot(P p0, P p1) { if (p0 == null || p1 == null || p0.isEmpty() | p1.isEmpty()) { throw new IllegalArgumentException("Null or empty Position passed."); } return -p0.getY() * p1.getX() + p0.getX() * p1.getY(); }
/** * Returns the Morton code for the specified {@code Point}. * * @param pos an {@code Point} value. * @return the morton code for the specified {@code Point} value. * @throws IllegalArgumentException if the value of the point parameter is null, or is not contained in * the spatial extent of this instance's {@code MortonContext} */ public String ofPosition(P pos) { //check inputs checkForNull(pos); checkWithinExtent(pos); int col = getCol(pos.getX()); int row = getRow(pos.getY()); long interleaved = interleave(col, row); return pointMortonCodeAsString(interleaved); }