de.jreality.geometry

## Class Primitives

• ```public class Primitives
extends Object```
Static methods for generating a variety of geometric primitives either as instances of `Geometry` or `SceneGraphComponent`. The main categories of primitives are:
• Polyhedra: cube, tetrahedron, icosahedron, pyramids, ...
• Approximations to smooth shapes: sphere, cylinder, torus, ...
• Points and rectangles
• Miscellaneous: clipping planes, ...

Note: many of these methods could perhaps profitably be replaced with factory classes.

Author:
Charles Gunn
• ### Field Summary

Fields
Modifier and Type Field and Description
`static double[][]` `icoVerts3`
`static IndexedFaceSet` `sharedIcosahedron`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static IndexedLineSet` ```arrow(double x0, double y0, double x1, double y1, double tipSize)```
`static IndexedLineSet` ```arrow(double x0, double y0, double x1, double y1, double tipSize, boolean halfArrow)```
Generate an an arrow: a line segment joining (x0,y0) to (x1,y1) with a head at the second point, each half making a 45 degree angle to the segment.
`static IndexedFaceSet` ```box(double width, double height, double depth, boolean colored)```
Same as `#box(double, double, double, boolean, Pn.EUCLIDEAN)`
`static IndexedFaceSet` ```box(double width, double height, double depth, boolean colored, int metric)```
A box centered at the origin.
`static IndexedFaceSetFactory` ```boxFactory(double width, double height, double depth, boolean colored, int metric)```
`static SceneGraphComponent` `clippingPlane(double[] plane)`
`static SceneGraphComponent` ```clippingPlane(double[] plane, int sig)```
Create a clipping plane with the given plane equation with the given metric.
`static SceneGraphComponent` ```closedCylinder(int n, double r, double zmin, double zmax, double thetamax)```
`static SceneGraphComponent` ```closedCylinder(int n, double r, double R, double zmin, double zmax, double thetamax)```
`static IndexedFaceSet` `coloredCube()`
`static IndexedFaceSet` ```coloredCube(double width, double height, double depth)```
Deprecated.
Use `#box(double, double, double, true)`
`static IndexedFaceSet` `coloredTetrahedron()`
`static IndexedFaceSet` `cone(int n)`
a simple cone with tip at (0,0,1) radius 1 on the XY axis
`static IndexedFaceSet` ```cone(int n, double h)```
`static IndexedFaceSet` `cube()`
`static IndexedFaceSet` `cube(boolean colored)`
A cube.
`static IndexedFaceSet` ```cube(double width, double height, double depth)```
Deprecated.
Use `#box(double, double, double, false)`
`static IndexedFaceSet` ```cube(double width, double height, double depth, boolean colored)```
Deprecated.
`static IndexedFaceSet` `cube4(boolean colored)`
A cube.
`static IndexedFaceSet` `cylinder(int n)`
A unit euclidean cylinder approximated by a prism with nsides.
`static IndexedFaceSet` ```cylinder(int n, double r, double zmin, double zmax, double thetamax)```
A renderMan-style cylinder specification (implicitly euclidean)
`static IndexedFaceSet` ```cylinder(int n, double r, double R, double zmin, double zmax, double thetamax)```
`static IndexedFaceSet` ```cylinder(int n, double r, double R, double zmin, double zmax, double thetamax, int res)```
`static IndexedLineSet` ```discreteTorusKnot(double R, double r, int n, int m, int nPts)```
Generate a torus knot that winds around the given torus the given number of times.
`static IndexedFaceSet` `icosahedron()`
`static SceneGraphComponent` ```labelPoint(SceneGraphComponent sgc, double[] center, String label)```
`static IndexedFaceSet` `openCube()`
`static PointSet` `point(double[] center)`
`static PointSet` ```point(double[] center, String label)```
A single point as a `PointSet`.
`static IndexedFaceSet` ```pyramid(double[][] base, double[] tip)```
A pyramid: a cone with vertex tip over the polygon base.
`static IndexedFaceSet` ```regularAnnulus(int order, double offset, double r)```
`static IndexedFaceSet` `regularPolygon(int order)`
Construct a regular polygon lying in the (x,y) plane, lying on the unit-circle there, and having order edges.
`static IndexedFaceSet` ```regularPolygon(int order, double offset)```
Construct a regular polygon lying in the (x,y) plane, lying on the unit-circle there, and having order edges.
`static IndexedFaceSetFactory` ```regularPolygonFactory(int order, double offset)```
`static double[][]` ```regularPolygonVertices(int order, double offset)```
`static SceneGraphComponent` ```sphere(double radius, double[] center)```
A euclidean sphere with given radius and center.
`static SceneGraphComponent` ```sphere(double radius, double[] center, int metric)```
A sphere with given radius and center, with the given metric metric.
`static SceneGraphComponent` ```sphere(double radius, double x, double y, double z)```
A euclidean sphere with given radius and center.
`static IndexedFaceSet` `sphere(int detail)`
Create a unit sphere centered at the origin using latitude/longitude parametrization.
`static IndexedFaceSet` `tetrahedron()`
`static IndexedFaceSet` `tetrahedron(boolean colored)`
A tetrahedron.
`static IndexedFaceSet` ```texturedBox(double width, double height, double depth)```
Generate a box with texture coordinates obtained from the vertex coordinates.
`static IndexedFaceSet` `texturedQuadrilateral()`
`static IndexedFaceSet` `texturedQuadrilateral(double[] points)`
`static IndexedFaceSetFactory` `texturedQuadrilateralFactory()`
Generate a textured quadrilateral using the given array points.
`static IndexedFaceSetFactory` `texturedQuadrilateralFactory(double[] points)`
`static IndexedFaceSet` ```torus(double bR, double sR, int bDetail, int sDetail)```
Create a torus with the given parameters.
`static SceneGraphComponent` `wireframeSphere()`
`static SceneGraphComponent` ```wireframeSphere(int w, int h)```
A `SceneGraphComponent` with wire-frame sphere (azimuth/elevation coordinate mesh)
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### icoVerts3

`public static double[][] icoVerts3`
• #### sharedIcosahedron

`public static IndexedFaceSet sharedIcosahedron`
• ### Method Detail

• #### cube

`public static IndexedFaceSet cube()`
• #### coloredCube

`public static IndexedFaceSet coloredCube()`
• #### openCube

`public static IndexedFaceSet openCube()`
• #### cube4

`public static IndexedFaceSet cube4(boolean colored)`
A cube. If colored is true, then it is given face colors. Has 4D vertices for using in non-euclidean settings.
Parameters:
`colored` -
Returns:
• #### cube

`public static IndexedFaceSet cube(boolean colored)`
A cube. If colored is true, then it is given face colors.
Parameters:
`colored` -
Returns:
• #### cube

```public static IndexedFaceSet cube(double width,
double height,
double depth,
boolean colored)```
Deprecated.
• #### box

```public static IndexedFaceSet box(double width,
double height,
double depth,
boolean colored)```
Same as `#box(double, double, double, boolean, Pn.EUCLIDEAN)`
Returns:
• #### box

```public static IndexedFaceSet box(double width,
double height,
double depth,
boolean colored,
int metric)```
A box centered at the origin.
Parameters:
`width` - x-dim
`height` - y-dim
`depth` - z-dim
`colored` - provide face colors?
`metric` - the metric
Returns:
• #### boxFactory

```public static IndexedFaceSetFactory boxFactory(double width,
double height,
double depth,
boolean colored,
int metric)```
• #### coloredCube

```public static IndexedFaceSet coloredCube(double width,
double height,
double depth)```
Deprecated. Use `#box(double, double, double, true)`
Parameters:
`width` -
`height` -
`depth` -
Returns:
• #### cube

```public static IndexedFaceSet cube(double width,
double height,
double depth)```
Deprecated. Use `#box(double, double, double, false)`
Parameters:
`width` -
`height` -
`depth` -
Returns:
• #### tetrahedron

`public static IndexedFaceSet tetrahedron()`
• #### coloredTetrahedron

`public static IndexedFaceSet coloredTetrahedron()`
• #### tetrahedron

`public static IndexedFaceSet tetrahedron(boolean colored)`
A tetrahedron. If colored is true, then it has face colors.
Parameters:
`colored` -
Returns:
• #### icosahedron

`public static IndexedFaceSet icosahedron()`
Returns:
• #### point

`public static PointSet point(double[] center)`
• #### point

```public static PointSet point(double[] center,
String label)```
A single point as a `PointSet`.
Parameters:
`center` -
Returns:
• #### labelPoint

```public static SceneGraphComponent labelPoint(SceneGraphComponent sgc,
double[] center,
String label)```
• #### sphere

```public static SceneGraphComponent sphere(double radius,
double x,
double y,
double z)```
A euclidean sphere with given radius and center.
Parameters:
`radius` -
`x` -
`y` -
`z` -
Returns:
• #### sphere

```public static SceneGraphComponent sphere(double radius,
double[] center)```
A euclidean sphere with given radius and center.
Parameters:
`radius` -
`center` -
Returns:
• #### sphere

```public static SceneGraphComponent sphere(double radius,
double[] center,
int metric)```
A sphere with given radius and center, with the given metric metric.
Parameters:
`radius` -
`center` -
`metric` -
Returns:
• #### wireframeSphere

`public static SceneGraphComponent wireframeSphere()`
• #### wireframeSphere

```public static SceneGraphComponent wireframeSphere(int w,
int h)```
A `SceneGraphComponent` with wire-frame sphere (azimuth/elevation coordinate mesh)
Returns:
• #### cylinder

`public static IndexedFaceSet cylinder(int n)`
A unit euclidean cylinder approximated by a prism with nsides. The cylinder has radius 1, is centered on the z-axis, and goes from z=-1 to z=1.
Parameters:
`n` -
Returns:
`Cylinder`
• #### cylinder

```public static IndexedFaceSet cylinder(int n,
double r,
double zmin,
double zmax,
double thetamax)```
A renderMan-style cylinder specification (implicitly euclidean)
Parameters:
`n` -
`r` -
`zmin` -
`zmax` -
`thetamax` -
Returns:
• #### cylinder

```public static IndexedFaceSet cylinder(int n,
double r,
double R,
double zmin,
double zmax,
double thetamax)```
• #### cylinder

```public static IndexedFaceSet cylinder(int n,
double r,
double R,
double zmin,
double zmax,
double thetamax,
int res)```
• #### closedCylinder

```public static SceneGraphComponent closedCylinder(int n,
double r,
double zmin,
double zmax,
double thetamax)```
• #### closedCylinder

```public static SceneGraphComponent closedCylinder(int n,
double r,
double R,
double zmin,
double zmax,
double thetamax)```
• #### cone

`public static IndexedFaceSet cone(int n)`
a simple cone with tip at (0,0,1) radius 1 on the XY axis
Parameters:
`n` -
Returns:
cone with no bottom
• #### cone

```public static IndexedFaceSet cone(int n,
double h)```
• #### pyramid

```public static IndexedFaceSet pyramid(double[][] base,
double[] tip)```
A pyramid: a cone with vertex tip over the polygon base. The polygon is assumed to be closed -- so the user need not set the last vertex to be the same as the first.
Parameters:
`base` -
`tip` -
Returns:
• #### discreteTorusKnot

```public static IndexedLineSet discreteTorusKnot(double R,
double r,
int n,
int m,
int nPts)```
Generate a torus knot that winds around the given torus the given number of times.
Parameters:
`R` - major radius
`r` - minor radius
`n` - number of windings around the big circle
`m` - number of windings around the small (meridianal) circle
`nPts` - how many segments in the resulting curve.
Returns:
• #### regularPolygon

`public static IndexedFaceSet regularPolygon(int order)`
Construct a regular polygon lying in the (x,y) plane, lying on the unit-circle there, and having order edges.
Parameters:
`order` -
Returns:
• #### regularPolygon

```public static IndexedFaceSet regularPolygon(int order,
double offset)```
Construct a regular polygon lying in the (x,y) plane, lying on the unit-circle there, and having order edges. Offset rotates vertices Offset 0.5 : an edge touches the X-axis Offset 0 : a vertex touches the X-axis Offset 1 equals 0
Parameters:
`order` - number of Vertices
`offset` -
Returns:
• #### regularPolygonFactory

```public static IndexedFaceSetFactory regularPolygonFactory(int order,
double offset)```
• #### regularPolygonVertices

```public static double[][] regularPolygonVertices(int order,
double offset)```
• #### regularAnnulus

```public static IndexedFaceSet regularAnnulus(int order,
double offset,
double r)```
• #### arrow

```public static IndexedLineSet arrow(double x0,
double y0,
double x1,
double y1,
double tipSize,
boolean halfArrow)```
Generate an an arrow: a line segment joining (x0,y0) to (x1,y1) with a head at the second point, each half making a 45 degree angle to the segment. If halfArrow is true, then only the left half of the arrow is drawn.
Parameters:
`x0` -
`y0` -
`x1` -
`y1` -
`tipSize` - Scaling factor for the head of the arrow. Value of 1 makes it as big as the arrow itself.
`halfArrow` -
Returns:
• #### clippingPlane

```public static SceneGraphComponent clippingPlane(double[] plane,
int sig)```
Create a clipping plane with the given plane equation with the given metric. The points whose inner product with plane are negative, will be clipped away.
Parameters:
`plane` -
`sig` -
Returns:
• #### torus

```public static IndexedFaceSet torus(double bR,
double sR,
int bDetail,
int sDetail)```
Create a torus with the given parameters. The resulting instance also has a `Geometry` `Attribute` so that the RenderMan viewer `de.jreality.renderman.RIBViewer` will produce an exact torus.
Parameters:
`bR` - Major radius
`sR` - Minor radius
`bDetail` - Number of sample points around major circle
`sDetail` - Number of sample points around minor circle
Returns:
• #### sphere

`public static IndexedFaceSet sphere(int detail)`
Create a unit sphere centered at the origin using latitude/longitude parametrization. detail specifies how many samples to use in both directions.
Parameters:
`detail` -
Returns:

`public static IndexedFaceSet texturedQuadrilateral()`

`public static IndexedFaceSet texturedQuadrilateral(double[] points)`

`public static IndexedFaceSetFactory texturedQuadrilateralFactory()`
Generate a textured quadrilateral using the given array points. This should have length 12 or 16, depending on whether the point coordinates are dehomogenized or not.
Parameters:
`points` -
Returns:
`public static IndexedFaceSetFactory texturedQuadrilateralFactory(double[] points)`
```public static IndexedFaceSet texturedBox(double width,
`width` - x-dim
`height` - y-dim
`depth` - z-dim