java.lang.Object
org.jgrapht.alg.drawing.model.Points
A collection of utilities to assist with point manipulation.
- Author:
- Dimitrios Michail
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Point2D
Add 2-dimensional vectorsstatic boolean
Compare two points for equality using tolerance 1e-9.static double
Compute the length of a vector.static Point2D
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 2-dimensional vectors
-
Constructor Details
-
Points
public Points()
-
-
Method Details
-
length
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
Add 2-dimensional vectors- Parameters:
a
- the first vectorb
- the second vector- Returns:
- the vector $a+b$
-
subtract
Subtract 2-dimensional vectors- Parameters:
a
- the first vectorb
- the second vector- Returns:
- the vector $a-b$
-
negate
Given a vector $a$ compute $-a$.- Parameters:
a
- the vector- Returns:
- the vector $-a$
-
scalarMultiply
Multiply a vector with a scalar.- Parameters:
a
- the vectorscalar
- the scalar- Returns:
- the result of scalar multiplication
-
scalarMultiply
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
-
equals
Compare two points for equality using tolerance 1e-9.- Parameters:
p1
- the first pointp2
- the second point- Returns:
- whether the two points are equal or not
-