public class UnitSphereSampling
extends java.lang.Object
Positive sample indices correspond to points in the upper hemisphere for which z>=0. Negative sample indices correspond to points in the lower hemisphere for which z<=0. The sample index zero corresponds to no point. Points on the equator (x,y,z=0) correspond to both negative and positive sample indices.
Points with positive and negative indices are sampled symmetrically about the center of the unit sphere. Specifically, if sample index i corresponds to a point (x,y,z), then sample index -i corresponds to the point (-x,-y,-z).
Constructor and Description |
---|
UnitSphereSampling()
Constructs a default sampling using sixteen bits per sample.
|
UnitSphereSampling(int nbits)
Constructs a sampling for the specified number of bits.
|
Modifier and Type | Method and Description |
---|---|
int |
countSamples()
Gets the number of points sampled on this unit sphere.
|
static short[][][] |
encode16(float[][][] x,
float[][][] y,
float[][][] z)
Encodes specified points as 16-bit (short) indices.
|
static short[][] |
encode16(float[][] x,
float[][] y,
float[][] z)
Encodes specified points as 16-bit (short) indices.
|
static short[] |
encode16(float[] x,
float[] y,
float[] z)
Encodes specified points as 16-bit (short) indices.
|
int |
getIndex(float[] xyz)
Gets the index of the sampled point nearest to the specified point.
|
int |
getIndex(float x,
float y,
float z)
Gets the index of the sampled point nearest to the specified point.
|
int |
getMaxIndex()
Gets the maximum sample index, a positive integer.
|
float[] |
getPoint(int index)
Gets the sampled point for the specified index, which must be non-zero.
|
int[] |
getTriangle(float[] xyz)
Gets an array {ia,ib,ic} of three sample indices for a spherical
triangle that contains the specified point.
|
int[] |
getTriangle(float x,
float y,
float z)
Gets an array {ia,ib,ic} of three sample indices for the spherical
triangle that contains the specified point.
|
float[] |
getWeights(float[] xyz,
int[] iabc)
Gets an array {wa,wb,wc} of three weights for a point in a spherical
triangle specified by sample indices of three points.
|
float[] |
getWeights(float x,
float y,
float z,
int[] iabc)
Gets an array {wa,wb,wc} of three weights for a point in a spherical
triangle specified by sample indices of three points.
|
static void |
main(java.lang.String[] args) |
public UnitSphereSampling()
public UnitSphereSampling(int nbits)
nbits
- the number of bits; 4 <= nbits <= 32 required.public int countSamples()
public int getMaxIndex()
This number equals the number of points sampled in one hemisphere, including points on the equator.
public float[] getPoint(int index)
index
- the index of the sampled point; must be non-zero.public int getIndex(float x, float y, float z)
x
- x-coordinate of the point.y
- y-coordinate of the point.z
- z-coordinate of the point.public int getIndex(float[] xyz)
xyz
- array {x,y,z} of point coordinates.public int[] getTriangle(float x, float y, float z)
x
- x-coordinate of the point.y
- y-coordinate of the point.z
- z-coordinate of the point.public int[] getTriangle(float[] xyz)
xyz
- array {x,y,z} of point coordinates.public float[] getWeights(float x, float y, float z, int[] iabc)
For example, let p denote the specified point with coordinates {x,y,z}, and let o denote the center of the sphere with coordinates {0,0,0}. Then the weight wa is proportional to the volume of the tetrahedron formed by points p, b, c, and o.
x
- x-coordinate of the point.y
- y-coordinate of the point.z
- z-coordinate of the point.iabc
- array {ia,ib,ic} of sample indices.public float[] getWeights(float[] xyz, int[] iabc)
For example, let p denote the specified point with coordinates {x,y,z}, and let o denote the center of the sphere with coordinates {0,0,0}. Then the weight wa is proportional to the volume of the tetrahedron formed by points p, b, c, and o.
xyz
- array {x,y,z} of point coordinates.iabc
- array {ia,ib,ic} of sample indices.public static short[] encode16(float[] x, float[] y, float[] z)
x
- array of x-coordinates of points.y
- array of y-coordinates of points.z
- array of z-coordinates of points.public static short[][] encode16(float[][] x, float[][] y, float[][] z)
x
- array of x-coordinates of points.y
- array of y-coordinates of points.z
- array of z-coordinates of points.public static short[][][] encode16(float[][][] x, float[][][] y, float[][][] z)
x
- array of x-coordinates of points.y
- array of y-coordinates of points.z
- array of z-coordinates of points.public static void main(java.lang.String[] args)