Class MinkowskiDistance
java.lang.Object
de.articdive.jnoise.generators.noise_parameters.distance_functions.MinkowskiDistance
- All Implemented Interfaces:
DistanceFunction
Interesting distance function that will be a bit more expensive to compute (especially for large values of p)
Also to note: p = 1 is the same as
DistanceFunctionType.MANHATTAN
and p = 2 is the same as DistanceFunctionType.EUCLIDEAN_SQUARED
, so don't use this for p = 1 and p = 2!-
Constructor Summary
ConstructorDescriptionMinkowskiDistance
(long p) Creates a new DistanceFunction using Minkowski's Distance formulas with a specified order. -
Method Summary
Modifier and TypeMethodDescriptiondouble
distance
(double x0, double x1) Gets the distance from a 1D point to another 1D point.double
distance
(double x0, double y0, double x1, double y1) Gets the distance from a 2D point to another 2D point.double
distance
(double x0, double y0, double z0, double x1, double y1, double z1) Gets the distance from a 3D point to another 3D point.double
distance
(double x0, double y0, double z0, double w0, double x1, double y1, double z1, double w1) Gets the distance from a 4D point to another 4D point.
-
Constructor Details
-
MinkowskiDistance
public MinkowskiDistance(long p) Creates a new DistanceFunction using Minkowski's Distance formulas with a specified order.- Parameters:
p
- The order of the distance function.
-
-
Method Details
-
distance
public double distance(double x0, double x1) Description copied from interface:DistanceFunction
Gets the distance from a 1D point to another 1D point.- Specified by:
distance
in interfaceDistanceFunction
- Parameters:
x0
- X-Coordinate of the first point.x1
- X-Coordinate of the second point.- Returns:
- a positive distance between P(x0) and Q(x1)
-
distance
public double distance(double x0, double y0, double x1, double y1) Description copied from interface:DistanceFunction
Gets the distance from a 2D point to another 2D point.- Specified by:
distance
in interfaceDistanceFunction
- Parameters:
x0
- X-Coordinate of the first point.y0
- Y-Coordinate of the first point.x1
- X-Coordinate of the second point.y1
- Y-Coordinate of the second point.- Returns:
- a positive distance between P(x0, y0) and Q(x1, y1)
-
distance
public double distance(double x0, double y0, double z0, double x1, double y1, double z1) Description copied from interface:DistanceFunction
Gets the distance from a 3D point to another 3D point.- Specified by:
distance
in interfaceDistanceFunction
- Parameters:
x0
- X-Coordinate of the first point.y0
- Y-Coordinate of the first point.z0
- Z-Coordinate of the first point.x1
- X-Coordinate of the second point.y1
- Y-Coordinate of the second point.z1
- Z-Coordinate of the second point.- Returns:
- a positive distance between (x0, y0, z0) and (x1, y1, z1)
-
distance
public double distance(double x0, double y0, double z0, double w0, double x1, double y1, double z1, double w1) Description copied from interface:DistanceFunction
Gets the distance from a 4D point to another 4D point.- Specified by:
distance
in interfaceDistanceFunction
- Parameters:
x0
- X-Coordinate of the first point.y0
- Y-Coordinate of the first point.z0
- Z-Coordinate of the first point.w0
- W-Coordinate of the first point.x1
- X-Coordinate of the second point.y1
- Y-Coordinate of the second point.z1
- Z-Coordinate of the second point.w1
- W-Coordinate of the second point.- Returns:
- a positive distance between (x0, y0, z0, w0) and (x1, y1, z1, w1)
-