- java.lang.Object
-
- org.jgrapht.alg.drawing.model.Points
-
public abstract class Points extends Object
A collection of utilities to assist with point manipulation.- Author:
- Dimitrios Michail
-
-
Constructor Summary
Constructors Constructor Description Points()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Point2D
add(Point2D a, Point2D b)
Add 2-dimensional vectorsstatic boolean
equals(Point2D p1, Point2D p2)
Compare two points for equality using tolerance 1e-9.static double
length(Point2D v)
Compute the length of a vector.static Point2D
negate(Point2D a)
Given a vector $a$ compute $-a$.static Point2D
scalarMultiply(Point2D a, double scalar)
Multiply a vector with a scalar.static <S> Point2D
scalarMultiply(Point2D a, S scalar, BiFunction<Double,S,Double> mult)
Multiply a vector with a scalar.static Point2D
subtract(Point2D a, Point2D b)
Subtract 2-dimensional vectors
-
-
-
Method Detail
-
length
public static double length(Point2D v)
Compute the length of a vector. The length of vector $(x,y)$ is given by $\sqrt{x^2+y^2}$.- Parameters:
v
- the vector- Returns:
- the length of a vector
-
add
public static Point2D add(Point2D a, Point2D b)
Add 2-dimensional vectors- Parameters:
a
- the first vectorb
- the second vector- Returns:
- the vector $a+b$
-
subtract
public static Point2D subtract(Point2D a, Point2D b)
Subtract 2-dimensional vectors- Parameters:
a
- the first vectorb
- the second vector- Returns:
- the vector $a-b$
-
negate
public static Point2D negate(Point2D a)
Given a vector $a$ compute $-a$.- Parameters:
a
- the vector- Returns:
- the vector $-a$
-
scalarMultiply
public static Point2D scalarMultiply(Point2D a, double scalar)
Multiply a vector with a scalar.- Parameters:
a
- the vectorscalar
- the scalar- Returns:
- the result of scalar multiplication
-
scalarMultiply
public static <S> Point2D scalarMultiply(Point2D a, S scalar, BiFunction<Double,S,Double> mult)
Multiply a vector with a scalar.- Type Parameters:
S
- the scalar type- Parameters:
a
- the vectorscalar
- the scalarmult
- the multiplication operator- Returns:
- the result of scalar multiplication
-
-