Package com.google.common.geometry
Class S2.Metric
java.lang.Object
com.google.common.geometry.S2.Metric
- Enclosing class:
S2
@GwtCompatible(emulated=true,
serializable=false)
public static final class S2.Metric
extends Object
Defines an area or a length cell metric.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMetric
(int dim, double deriv) Defines a cell metric of the given dimension (1 == length, 2 == area). -
Method Summary
Modifier and TypeMethodDescriptiondouble
deriv()
The "deriv" value of a metric is a derivative, and must be multiplied by a length or area in (s,t)-space to get a useful value.int
getClosestLevel
(double value) Return the level at which the metric has approximately the given value.int
getMaxLevel
(double value) Return the maximum level such that the metric is at least the given value, or zero if there is no such level.int
getMinLevel
(double value) Return the minimum level such that the metric is at most the given value, or S2CellId::kMaxLevel if there is no such level.double
getValue
(int level) Return the value of a metric for cells at the given level.
-
Field Details
-
deriv
private final double deriv -
dim
private final int dim
-
-
Constructor Details
-
Metric
public Metric(int dim, double deriv) Defines a cell metric of the given dimension (1 == length, 2 == area).
-
-
Method Details
-
deriv
public double deriv()The "deriv" value of a metric is a derivative, and must be multiplied by a length or area in (s,t)-space to get a useful value. -
getValue
public double getValue(int level) Return the value of a metric for cells at the given level. -
getClosestLevel
public int getClosestLevel(double value) Return the level at which the metric has approximately the given value. For example, S2::kAvgEdge.GetClosestLevel(0.1) returns the level at which the average cell edge length is approximately 0.1. The return value is always a valid level. -
getMinLevel
public int getMinLevel(double value) Return the minimum level such that the metric is at most the given value, or S2CellId::kMaxLevel if there is no such level. For example, S2::kMaxDiag.GetMinLevel(0.1) returns the minimum level such that all cell diagonal lengths are 0.1 or smaller. The return value is always a valid level. -
getMaxLevel
public int getMaxLevel(double value) Return the maximum level such that the metric is at least the given value, or zero if there is no such level. For example, S2.kMinWidth.GetMaxLevel(0.1) returns the maximum level such that all cells have a minimum width of 0.1 or larger. The return value is always a valid level.
-