Package org.geolatte.geom
Class Vector
- java.lang.Object
-
- org.geolatte.geom.Vector
-
public class Vector extends Object
A set of utility functions for basic 2D vector functions.- Author:
- Karel Maesen, Geovise BVBA creation-date: 4/7/12
-
-
Constructor Summary
Constructors Constructor Description Vector()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <P extends C2D>
Padd(P p0, P p1)Adds twoPositions.static <P extends C2D>
doubledot(P p0, P p1)Returns the dot-product of the specifiedPositionsstatic <P extends C2D>
Pperp(P p)Hill's "perp" operator.static <P extends C2D>
doubleperpDot(P p0, P p1)Applies the perp dot-operation on the specifiedPositionsstatic <P extends C2D>
double[]positionToSegment2D(P p0, P p1, P y)Returns the squared distance and projectionfactor of the position y on the linesegment defined by positions p0 and p1static <P extends C2D>
Psubstract(P p0, P p1)Subtracts twoPositions.
-
-
-
Method Detail
-
positionToSegment2D
public static <P extends C2D> double[] positionToSegment2D(P p0, P p1, P y)
Returns the squared distance and projectionfactor of the position y on the linesegment defined by positions p0 and p1The projection factor is the value for t that determines the projection of y on the line p0 + t*(p1-p0).
- Parameters:
p0- the start position of the line segmentp1- the end position of the line segmenty- the position to project onto the linesegment- Returns:
- an array of length 2, with first element being the squared distance of Position y to the linesegment, and second element the projection factor
-
dot
public static <P extends C2D> double dot(P p0, P p1)
Returns the dot-product of the specifiedPositions- Parameters:
p0- first operandp1- second operand- Returns:
- the dot-product of p0 and p1.
-
add
public static <P extends C2D> P add(P p0, P p1)
Adds twoPositions.If any of the parameters are 2D, the operation is performed in 2D.
- Parameters:
p0- first operandp1- second operand- Returns:
- the sum of p0 and p1.
-
substract
public static <P extends C2D> P substract(P p0, P p1)
Subtracts twoPositions.If any of the parameters are 2D, the operation is performed in 2D.
- Parameters:
p0- first operandp1- second operand- Returns:
- the Position x = p0 - p1.
-
perp
public static <P extends C2D> P perp(P p)
Hill's "perp" operator.The application of this operator on a vector
Preturns the vector perpendicular at 90 deg. counterclockwise fromPin the 2D (X/Y) plane.- Parameters:
p- a vector represented by a Position.- Returns:
- the vector perpendicular to p in the 2D-plane, at 90 deg. counterclockwise.
-
perpDot
public static <P extends C2D> double perpDot(P p0, P p1)
Applies the perp dot-operation on the specifiedPositionsThe perp dot operation on vectors
P,Qis defined asdot(perp(P),Q).This operation will be performed in 2D only.
- Parameters:
p0- first operandp1- second operand- Returns:
- the Perp dot of p0 and p1.
-
-