Class InterpolatingMicrosphere
- java.lang.Object
-
- org.apache.commons.math3.analysis.interpolation.InterpolatingMicrosphere
-
- Direct Known Subclasses:
InterpolatingMicrosphere2D
public class InterpolatingMicrosphere extends java.lang.ObjectUtility class for theMicrosphereProjectionInterpolatoralgorithm.- Since:
- 3.6
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classInterpolatingMicrosphere.FacetMicrosphere "facet" (surface element).private static classInterpolatingMicrosphere.FacetDataData associated with eachInterpolatingMicrosphere.Facet.
-
Field Summary
Fields Modifier and Type Field Description private doublebackgroundBackground value.private doubledarkThresholdLowest non-zero illumination.private intdimensionSpace dimension.private doublemaxDarkFractionMaximum fraction of the facets that can be dark.private java.util.List<InterpolatingMicrosphere.Facet>microsphereMicrosphere.private java.util.List<InterpolatingMicrosphere.FacetData>microsphereDataMicrosphere data.private intsizeNumber of surface elements.
-
Constructor Summary
Constructors Modifier Constructor Description protectedInterpolatingMicrosphere(int dimension, int size, double maxDarkFraction, double darkThreshold, double background)Create an unitialiazed sphere.InterpolatingMicrosphere(int dimension, int size, double maxDarkFraction, double darkThreshold, double background, UnitSphereRandomVectorGenerator rand)Create a sphere from randomly sampled vectors.protectedInterpolatingMicrosphere(InterpolatingMicrosphere other)Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadd(double[] normal, boolean copy)Replacei-th facet of the microsphere.private voidclear()Reset the all thefacetsdata to zero.InterpolatingMicrospherecopy()Perform a copy.intgetDimension()Get the space dimensionality.intgetSize()Get the size of the sphere.private voidilluminate(double[] sampleDirection, double sampleValue, double weight)Illumination.private doubleinterpolate()Interpolation.doublevalue(double[] point, double[][] samplePoints, double[] sampleValues, double exponent, double noInterpolationTolerance)Estimate the value at the requested location.
-
-
-
Field Detail
-
microsphere
private final java.util.List<InterpolatingMicrosphere.Facet> microsphere
Microsphere.
-
microsphereData
private final java.util.List<InterpolatingMicrosphere.FacetData> microsphereData
Microsphere data.
-
dimension
private final int dimension
Space dimension.
-
size
private final int size
Number of surface elements.
-
maxDarkFraction
private final double maxDarkFraction
Maximum fraction of the facets that can be dark.
-
darkThreshold
private final double darkThreshold
Lowest non-zero illumination.
-
background
private final double background
Background value.
-
-
Constructor Detail
-
InterpolatingMicrosphere
protected InterpolatingMicrosphere(int dimension, int size, double maxDarkFraction, double darkThreshold, double background)Create an unitialiazed sphere. Sub-classes are responsible for calling theadd(double[]) addmethod in order to initialize all the sphere's facets.- Parameters:
dimension- Dimension of the data space.size- Number of surface elements of the sphere.maxDarkFraction- Maximum fraction of the facets that can be dark. If the fraction of "non-illuminated" facets is larger, no estimation of the value will be performed, and thebackgroundvalue will be returned instead.darkThreshold- Value of the illumination below which a facet is considered dark.background- Value returned when themaxDarkFractionthreshold is exceeded.- Throws:
NotStrictlyPositiveException- ifdimension <= 0orsize <= 0.NotPositiveException- ifdarkThreshold < 0.OutOfRangeException- ifmaxDarkFractiondoes not belong to the interval[0, 1].
-
InterpolatingMicrosphere
public InterpolatingMicrosphere(int dimension, int size, double maxDarkFraction, double darkThreshold, double background, UnitSphereRandomVectorGenerator rand)Create a sphere from randomly sampled vectors.- Parameters:
dimension- Dimension of the data space.size- Number of surface elements of the sphere.rand- Unit vector generator for creating the microsphere.maxDarkFraction- Maximum fraction of the facets that can be dark. If the fraction of "non-illuminated" facets is larger, no estimation of the value will be performed, and thebackgroundvalue will be returned instead.darkThreshold- Value of the illumination below which a facet is considered dark.background- Value returned when themaxDarkFractionthreshold is exceeded.- Throws:
DimensionMismatchException- if the size of the generated vectors does not match the dimension set in the constructor.NotStrictlyPositiveException- ifdimension <= 0orsize <= 0.NotPositiveException- ifdarkThreshold < 0.OutOfRangeException- ifmaxDarkFractiondoes not belong to the interval[0, 1].
-
InterpolatingMicrosphere
protected InterpolatingMicrosphere(InterpolatingMicrosphere other)
Copy constructor.- Parameters:
other- Instance to copy.
-
-
Method Detail
-
copy
public InterpolatingMicrosphere copy()
Perform a copy.- Returns:
- a copy of this instance.
-
getDimension
public int getDimension()
Get the space dimensionality.- Returns:
- the number of space dimensions.
-
getSize
public int getSize()
Get the size of the sphere.- Returns:
- the number of surface elements of the microspshere.
-
value
public double value(double[] point, double[][] samplePoints, double[] sampleValues, double exponent, double noInterpolationTolerance)Estimate the value at the requested location. This microsphere is placed at the givenpoint, contribution of the givensamplePointsto each sphere facet is computed (illumination) and the interpolation is performed (integration of the illumination).- Parameters:
point- Interpolation point.samplePoints- Sampling data points.sampleValues- Sampling data values at the correspondingsamplePoints.exponent- Exponent used in the power law that computes the weights (distance dimming factor) of the sample data.noInterpolationTolerance- When the distance between thepointand one of thesamplePointsis less than this value, no interpolation will be performed, and the value of the sample will just be returned.- Returns:
- the estimated value at the given
point. - Throws:
NotPositiveException- ifexponent < 0.
-
add
protected void add(double[] normal, boolean copy)Replacei-th facet of the microsphere. Method for initializing the microsphere facets.- Parameters:
normal- Facet's normal vector.copy- Whether to copy the given array.- Throws:
DimensionMismatchException- if the length ofndoes not match the space dimension.MaxCountExceededException- if the method has been called more times than the size of the sphere.
-
interpolate
private double interpolate()
Interpolation.- Returns:
- the value estimated from the current illumination of the microsphere.
-
illuminate
private void illuminate(double[] sampleDirection, double sampleValue, double weight)Illumination.- Parameters:
sampleDirection- Vector whose origin is at the interpolation point and tail is at the sample location.sampleValue- Data value of the sample.weight- Weight.
-
clear
private void clear()
Reset the all thefacetsdata to zero.
-
-