|
JClass DesktopViews 6.3.0 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.klg.jclass.chart3d.data.JCData3dUtil
Field Summary | |
static int |
DATA_INTERPOLATE_CUBIC
|
static int |
DATA_INTERPOLATE_LINEAR
|
Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Constructor Summary | |
JCData3dUtil()
|
Method Summary | |
static double |
computeInverseWeightedAverage(double[] values,
double[] weights,
double centreWeight,
int centreIndex,
double holeValue)
Generates a weighted average value for a data point based on its own value, as well as contributions from values contained in the values array. |
static com.klg.jclass.chart3d.Chart3dGridDataModel |
createCubicSampledDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source,
double[] xSamples,
double[] ySamples)
Constructs a data model by taking xSamples.length and ySamples.length
samples along the x and y axes of the source. |
static com.klg.jclass.chart3d.Chart3dGridDataModel |
createCubicSampledDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source,
RectangularShape dataWindow,
int xSampleSize,
int ySampleSize)
Constructs a data model by taking xSampleSize and ySampleSize samples
along the x and y axes of the source. |
static void |
createCubicSplineCoefficients(double[] x,
double[] y,
double[] a,
double[] b,
double[] c,
double[] d,
int n)
Fits a piecewise cubic spline to the series of x,y points. |
static com.klg.jclass.chart3d.Chart3dGridDataModel |
createDataCopy(com.klg.jclass.chart3d.Chart3dGridDataModel source)
Constructs a copy of the Chart3dGridDataModel source and returns it. |
static com.klg.jclass.chart3d.Chart3dGridDataModel |
createLinearSampledDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source,
double[] xSamples,
double[] ySamples)
Constructs a data model by taking xSamples.length and ySamples.length
samples along the x and y axes of the source. |
static com.klg.jclass.chart3d.Chart3dGridDataModel |
createLinearSampledDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source,
RectangularShape dataWindow,
int xSampleSize,
int ySampleSize)
Constructs a data model by taking xSampleSize and ySampleSize samples
along the x and y axes of the source. |
static void |
createLinearSplineCoefficients(double[] x,
double[] y,
double[] a,
double[] b,
int n)
Fits a piecewise linear spline to the series of x,y points. |
static void |
createShadedDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source,
com.klg.jclass.chart3d.Chart3dGridDataModel dest,
double sweepAngle,
double riseAngle,
double brightness,
double ambient)
Constructs an array of z values for the specified Chart3dGridDataModel
source where each z value is a measurement of light on the closed range
[0,1]. |
static com.klg.jclass.chart3d.Chart3dGridDataModel |
createShadedDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source,
double sweepAngle,
double riseAngle,
double brightness,
double ambient)
Constructs an array of z values for the specified Chart3dGridDataModel
source where each z value is a measurement of light on the closed range
[0,1]. |
static void |
createSmoothedDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source,
com.klg.jclass.chart3d.Chart3dGridDataModel dest,
double centreWeight)
Constructs a data model with a data surface with the same x and y grid values of source, but with "smoothed" z values. |
static com.klg.jclass.chart3d.Chart3dGridDataModel |
createSmoothedDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source,
double centreWeight)
Constructs a data model with a data surface with the same x and y grid values of source, but with "smoothed" z values. |
static void |
dataCopy(com.klg.jclass.chart3d.Chart3dGridDataModel source,
com.klg.jclass.chart3d.Chart3dGridDataModel dest)
Copies the xGrid, yGrid, and zValues of the source argument into the dest argument. |
static double |
estimateInitialSlopeOfCurve(double x0,
double y0,
double x1,
double y1,
double x2,
double y2)
Estimates the initial slope of the curve which contains the points (x0, y0), (x1, y1), (x2, y2). |
static double |
evaluateCubicSpline(double x,
double a,
double b,
double c,
double d)
Evaluates the cubic spline defined by f(x) = a + bx + c^2 + dx^3 at the specified parameter x value and returns the result. |
static double |
evaluateLinearSpline(double x,
double a,
double b)
Evaluates the linear spline defined by f(x) = a + bx at the specified parameter x and returns the result. |
static int |
findInsertionIndex(double value,
double[] values)
Returns the index whereby value would be inserted into the specified array values to maintain ascending order. |
static int |
findInsertionIndex(double value,
double[] values,
int n)
This method is identical to findInsertionIndex(double, double[]) , except
that it restricts the valid range of values to [values[0], values[n-1]]. |
static double |
getHoleValue(com.klg.jclass.chart3d.Chart3dDataModel model)
A convenience method which returns the hole value for the specified Chart3dDataModel . |
static int |
getSizeX(com.klg.jclass.chart3d.Chart3dGridDataModel model)
A convenience method which returns the size of the specified data model's x grid, or 0 if the model has no x data. |
static int |
getSizeY(com.klg.jclass.chart3d.Chart3dGridDataModel model)
A convenience method which returns the size of the specified data model's y grid, or 0 if the model has no y data. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DATA_INTERPOLATE_LINEAR
public static final int DATA_INTERPOLATE_CUBIC
Constructor Detail |
public JCData3dUtil()
Method Detail |
public static com.klg.jclass.chart3d.Chart3dGridDataModel createDataCopy(com.klg.jclass.chart3d.Chart3dGridDataModel source)
Chart3dGridDataModel
source and returns it.
Only the xGrid, yGrid, and zValues are copied.
source
- the data model to copy
public static void dataCopy(com.klg.jclass.chart3d.Chart3dGridDataModel source, com.klg.jclass.chart3d.Chart3dGridDataModel dest)
source
- dest
- public static com.klg.jclass.chart3d.Chart3dGridDataModel createShadedDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source, double sweepAngle, double riseAngle, double brightness, double ambient)
Chart3dGridDataModel
source where each z value is a measurement of light on the closed range
[0,1]. The amount of light at a given grid point has two components:
ambient and reflected.
The ambient component is constant for all grid points, and is specified by the ambient argument (which must be on the range [0,1]).
The reflected component is the dot product of two vectors. The first
is the light normal - a unit vector defined by the sweepAngle
and riseAngle
arguments. The sweepAngle
is the position of the light source measured in
degrees from the positive x axis in the xy plane. The riseAngle
is the
position of the light source measured in degrees above the xy plane. The
second is the surface normal - a unit vector computed at each individual
grid point.
The light at a given grid point is given by: light(x,y) = ambient + (1-ambient) * lightNormal·surfaceNormal(x,y)
The total amount of light at a given grid point is then adjusted for overall brightness by: lightAdjusted(x,y) = brightness * light(x,y) where brightness is on the closed range [0,1].
The source Chart3dGridDataModel
is cloned, and the shaded values are then
put into the array of z-values belogning to the clone.
z-values belong to the Chart3dGridDataModel
dest.
source
- the non-null data model used to compute the shaded datasweepAngle
- riseAngle
- brightness
- ambient
-
Chart3dGridDataModel
containing the same x
and y grid as source, and z-values corresponding to the
array of shaded values at each grid pointpublic static void createShadedDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source, com.klg.jclass.chart3d.Chart3dGridDataModel dest, double sweepAngle, double riseAngle, double brightness, double ambient)
Chart3dGridDataModel
source where each z value is a measurement of light on the closed range
[0,1]. The amount of light at a given grid point has two components:
ambient and reflected.
The ambient component is constant for all grid points, and is specified by the ambient argument (which must be on the range [0,1]).
The reflected component is the dot product of two vectors. The first
is the light normal - a unit vector defined by the sweepAngle
and riseAngle
arguments. The sweepAngle
is the position of the light source measured in
degrees from the positive x axis in the xy plane. The riseAngle
is the
position of the light source measured in degrees above the xy plane. The
second is the surface normal - a unit vector computed at each individual
grid point.
The light at a given grid point is given by: light(x,y) = ambient + (1-ambient) * lightNormal·surfaceNormal(x,y)
The total amount of light at a given grid point is then adjusted for overall brightness by: lightAdjusted(x,y) = brightness * light(x,y) where brightness is on the closed range [0,1].
The resultant light for each grid point is then stored in the array of
z-values belogning to the Chart3dGridDataModel
dest.
source
- the non-null data model used to compute the shaded datadest
- the non-null data model used to store the resultant shaded
datasweepAngle
- riseAngle
- brightness
- ambient
- public static com.klg.jclass.chart3d.Chart3dGridDataModel createSmoothedDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source, double centreWeight)
The smoothing
algorithm is a centre weighted average algorithm which functions as
follows:
Each smoothed z value is a combination of itself, as well as a contribution
from all immediate neighbouring z values (values to the West, Northwest,
North, NorthWest, and so on). The contribution that the candidate itself makes is
proportional to the centreWeight
argument, which can be anywhere from 0.0
(no contribution) to 1.0 (100% contribution). Any remaining contribution
is divided amongst all other contributors and is inversely proportional
to the distance from the each neighbour to the candidate.
Note: Any data
holes will remain data holes, and will not contribuite to the smoothed values
of its neighbours.
The source data model is not affected by this method.
source
- the data model used to construct the smoothed valuescentreWeight
-
IllegalArgumentException
- if there are fewer than 2x2 data valuespublic static void createSmoothedDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source, com.klg.jclass.chart3d.Chart3dGridDataModel dest, double centreWeight)
The smoothing algorithm is a centre weighted average algorithm which functions as follows:
Each smoothed z value is a combination of itself, as well as a contribution
from all immediate neighbouring z values (values to the West, Northwest,
North, NorthWest, and so on). The contribution that the candidate itself makes is
proportional to the centreWeight
argument which can be anywhere from 0.0
(no contribution) to 1.0 (100% contribution). Any remaining contribution
is divided amongst all other contributors and is inversely proportional
to the distance from the each neighbour to the candidate.
Note: Any data
holes will remain data holes, and will not contribuite to the smoothed values
of its neighbours.
The source data model is not affected by this method.
source
- the data model used to construct the smoothed valuesdest
- the data model used to store the smoothed valuescentreWeight
-
IllegalArgumentException
- An IllegalArgumentException if there are fewer than 2x2 data values.public static double computeInverseWeightedAverage(double[] values, double[] weights, double centreWeight, int centreIndex, double holeValue)
weightedSum
is the sum of all weights except for weights[centreIndex].
The weighted average is essentially just the sum of every contribution.
If hasHoles
is true
, all values which are equal to holeValue
will
be ignored and will not impact the weighted average computation.
values
- weights
- centreWeight
- centreIndex
- holeValue
-
public static int findInsertionIndex(double value, double[] values)
For example, if value
is 2.8 and values
is [0.0, 2.5, 3.1, 4.5], then
2 is returned. Note the following boundary conditions for the above
values: if value
is 0.0, 1 is returned; if value
is 4.5, 3 is returned.
value
- values
-
value
is less than values[0] or greater than
values[length-1]public static int findInsertionIndex(double value, double[] values, int n)
findInsertionIndex(double, double[])
, except
that it restricts the valid range of values to [values[0], values[n-1]].
value
- values
- n
-
public static void createLinearSplineCoefficients(double[] x, double[] y, double[] a, double[] b, int n)
The a and b coefficients are placed into the a and b arrays, respectively.
x
- y
- a
- b
- n
- public static void createCubicSplineCoefficients(double[] x, double[] y, double[] a, double[] b, double[] c, double[] d, int n)
x
- y
- a
- b
- c
- d
- n
- the number of intervals on which to generate spline coefficientspublic static double evaluateCubicSpline(double x, double a, double b, double c, double d)
x
- a
- b
- c
- d
-
public static double evaluateLinearSpline(double x, double a, double b)
x
- a
- b
-
public static double estimateInitialSlopeOfCurve(double x0, double y0, double x1, double y1, double x2, double y2)
x0
- y0
- x1
- y1
- x2
- y2
-
public static com.klg.jclass.chart3d.Chart3dGridDataModel createLinearSampledDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source, RectangularShape dataWindow, int xSampleSize, int ySampleSize)
xSampleSize
and ySampleSize
samples
along the x and y axes of the source. The first x sample is taken
along the source x axis at dataWindow.getMinX()
, and the last at
dataWindow.getMaxX()
. The first y sample is taken along
the source y axis at dataWindow.getMinY()
, and the last at
dataWindow.getMaxY()
. All samples are equally spaced between the
first and last samples along each axis respectively.
The zValues at each sample location are computed by interpolation of a series of piecewise linear splines which are fitted to the data values in both the x and y directions.
source
- dataWindow
- xSampleSize
- ySampleSize
-
Chart3dGridDataModel
, or null (if source is null)
NullPointerException
- If any of source or dataWindow is null.
IllegalArgumentException
- If the source data model contains fewer
than a 2x2 grid of data values, or if xSampleSize
or ySampleSize
is less
than 2.public static com.klg.jclass.chart3d.Chart3dGridDataModel createLinearSampledDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source, double[] xSamples, double[] ySamples)
xSamples.length
and ySamples.length
samples along the x and y axes of the source. The samples of the source
data will be taken at locations defined by a grid formed by the xSamples
and ySamples
arrays. To function properly, both of these arrays
should be in ascending order.
The Values
at each sample location are computed by interpolation of a
series of piecewise linear splines which are fitted to the data values
in both the x and y directions.
source
- xSamples
- ySamples
-
Chart3dGridDataModel
, or null (if source is null)
NullPointerException
- If any of source, xSamples
, or ySamples
is
null.
IllegalArgumentException
- If the source data model contains fewer
than a 2x2 grid of data values, or if xSamples
or ySamples
contains fewer
than 2 samples.public static com.klg.jclass.chart3d.Chart3dGridDataModel createCubicSampledDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source, double[] xSamples, double[] ySamples)
xSamples.length
and ySamples.length
samples along the x and y axes of the source. The samples of the source
data will be taken at locations defined by a grid formed by the xSamples
and ySamples
arrays. To function properly, both of these arrays
should be in ascending order.
The zValues
at each sample location are computed by interpolation of a
series of piecewise cubic splines which are fitted to the data values
in both the x and y directions. The cubic interpolation generally
results in a more authentic approximation to the data than a linear
interpolation.
Note: If there are fewer than 3 available data
values along a given axis, linear interpolation will be used by default.
source
- xSamples
- ySamples
-
Chart3dGridDataModel
, or null (if source is null)
NullPointerException
- If any of source, xSamples
, or ySamples
is
null.
IllegalArgumentException
- If the source data model contains fewer
than a 2x2 grid of data values, or if xSamples
or ySamples
contains fewer
than 2 samples.public static com.klg.jclass.chart3d.Chart3dGridDataModel createCubicSampledDataModel(com.klg.jclass.chart3d.Chart3dGridDataModel source, RectangularShape dataWindow, int xSampleSize, int ySampleSize)
xSampleSize
and ySampleSize
samples
along the x and y axes of the source. The first x sample is taken
along the source x axis at dataWindow.getMinX()
, and the last at
dataWindow.getMaxX()
. The first y sample is taken along
the source y axis at dataWindow.getMinY()
, and the last at
dataWindow.getMaxY()
. All samples are equally spaced between the
first and last samples along each axis respectively.
The zValues
at each sample location are computed by interpolation of a
series of piecewise cubic splines which are fitted to the data values
in both the x and y directions. The cubic interpolation generally
results in a more authentic approximation to the data than a linear
interpolation. Note however that if there are fewer than 3 available data
values along a given axis, linear interpolation will be used by default.
source
- dataWindow
- xSampleSize
- ySampleSize
-
Chart3dGridDataModel
, or null (if source is null)
NullPointerException
- If any of source or dataWindow
is null.
IllegalArgumentException
- If the source data model contains fewer
than a 2x2 grid of data values, or if xSampleSize
or ySampleSize
is less
than 2.public static double getHoleValue(com.klg.jclass.chart3d.Chart3dDataModel model)
Chart3dDataModel
. If the model implements the
HoleValue3dDataModel
interface, returns
HoleValue3dDataModel.getHoleValue()
; otherwise, returns
HoleValue3dDataModel.DEFAULT_HOLE_VALUE
.
model
-
public static int getSizeX(com.klg.jclass.chart3d.Chart3dGridDataModel model)
model
-
public static int getSizeY(com.klg.jclass.chart3d.Chart3dGridDataModel model)
model
-
|
Copyright © 2004 Quest Software Inc.. All rights reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |