de.jreality.geometry
Class SphereUtility

java.lang.Object
  extended by de.jreality.geometry.SphereUtility

public class SphereUtility
extends java.lang.Object

Static methods for generating approximations to spheres. The approximations are based either on subdividing a cube, or subdividing an icosahedron. These methods are used for example in the package de.jreality.jogl for quick rendering of spherical representations of points.

Warning: the approximation methods here have an upper limit on the fineness of the approximation which they are prepared to calculate. These limits should problably be removed.

Author:
Charles Gunn

Field Summary
static int SPHERE_COARSE
           
static int SPHERE_FINE
           
static int SPHERE_FINER
           
static int SPHERE_FINEST
           
static int SPHERE_SUPERFINE
           
static int SPHERE_WAYFINE
           
 
Method Summary
static void assignSphericalUVs(PointSet ps, double[] center)
           
static void colorizeSphere(PointSet ps, double[] center, ColorGradient cg)
          Calculated the distance from center ( [0,0,0] if center is null ) for each vertex and sets vertex colors from the given Color Gradient (d_min->0, d_max-_1).
static void dispose()
           
static Rectangle3D getSphereBoundingBox()
          Return a standard bounding box for a unit sphere.
static IndexedFaceSet sphericalPatch(double cU, double cV, double uSize, double vSize, int xDetail, int yDetail, double radius)
           
static QuadMeshFactory sphericalPatchFactory(double cU, double cV, double uSize, double vSize, int xDetail, int yDetail, double radius)
          Generate a spherical patch.
static SceneGraphComponent tessellatedCubeSphere(int i)
          Return a tessellated cube of order i.
static SceneGraphComponent tessellatedCubeSphere(int i, boolean sharedInstance)
           
static IndexedFaceSet tessellatedIcosahedronSphere(int i)
           
static IndexedFaceSet tessellatedIcosahedronSphere(int i, boolean sharedInstance)
          Return a tessellated icosahedron of order i.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPHERE_COARSE

public static int SPHERE_COARSE

SPHERE_FINE

public static int SPHERE_FINE

SPHERE_FINER

public static int SPHERE_FINER

SPHERE_FINEST

public static int SPHERE_FINEST

SPHERE_SUPERFINE

public static int SPHERE_SUPERFINE

SPHERE_WAYFINE

public static int SPHERE_WAYFINE
Method Detail

dispose

public static void dispose()

tessellatedIcosahedronSphere

public static IndexedFaceSet tessellatedIcosahedronSphere(int i)

tessellatedIcosahedronSphere

public static IndexedFaceSet tessellatedIcosahedronSphere(int i,
                                                          boolean sharedInstance)
Return a tessellated icosahedron of order i. That is, the triangular faces of an icosahedron are binary subdivided i times, the vertices are projected onto the unit sphere, and the result is returned. If sharedInstance is true, then the returned copy is a shared instance which should not be written on. The resulting polyhedra has 20*(4^i) faces. If i>7, it is clamped to 7 and the result is returned.

Parameters:
i -
sharedInstance -
Returns:

tessellatedCubeSphere

public static SceneGraphComponent tessellatedCubeSphere(int i)
Return a tessellated cube of order i. That is, the square faces of an cube are evenly subdivided into i2 smaller squares, and the vertices are projected onto the unit sphere. If sharedInstance is true, then the returned copy is a shared instance which should not be written on. The resulting polyhedra has 6*(i2) faces.If i>15, it is clamped to 15 and the result is returned.

Parameters:
i -
Returns:

tessellatedCubeSphere

public static SceneGraphComponent tessellatedCubeSphere(int i,
                                                        boolean sharedInstance)

getSphereBoundingBox

public static Rectangle3D getSphereBoundingBox()
Return a standard bounding box for a unit sphere.

Returns:

sphericalPatch

public static IndexedFaceSet sphericalPatch(double cU,
                                            double cV,
                                            double uSize,
                                            double vSize,
                                            int xDetail,
                                            int yDetail,
                                            double radius)

sphericalPatchFactory

public static QuadMeshFactory sphericalPatchFactory(double cU,
                                                    double cV,
                                                    double uSize,
                                                    double vSize,
                                                    int xDetail,
                                                    int yDetail,
                                                    double radius)
Generate a spherical patch. (cU, cV) specify the center of the patch in spherical angles (longitude, latitude) in radians.

Parameters:
cU -
cV -
uSize - wdith of the patch (longitude)
vSize - height of the patch (latitude)
n - number of sample points in u
m - number of sample points in v
r - radius of the sphere
Returns:

colorizeSphere

public static void colorizeSphere(PointSet ps,
                                  double[] center,
                                  ColorGradient cg)
Calculated the distance from center ( [0,0,0] if center is null ) for each vertex and sets vertex colors from the given Color Gradient (d_min->0, d_max-_1).

Parameters:
ps - the PointSet to set vertex colors
center - optional center
cg - optional color color gradient TODO: adapt to homogenious coordinates

assignSphericalUVs

public static void assignSphericalUVs(PointSet ps,
                                      double[] center)