|
j3d.org Code | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.j3d.geom.GeometryGenerator org.j3d.geom.SuperShapeGenerator
public class SuperShapeGenerator
Generalised shape generator that is capable of generating almost any 2D shape using a standard algorithm.
This class generates 3D coordinates for a single flat object in the X,Y plane with a Z value of zero. Because this is only generating 2D shapes in reality, it only supports the LINE_ geometry types. All Triangle and quad forms are not supported.
The basic equation for a supershape comes from the standard form that you are familiar with for any ellipsoid.
(x / a)^2 + (y / b)^2 = r^2Turning this into polar coordinates, the equation becomes
m = 0. This results in circles, namely r = 1 | |||||
n1 = n2 = n3 = 1 Increasing m adds rotational symmetry to the shape. This is generally the case for other values of the n parameters. The curves are repeated in sections of the circle of angle 2 * pi/m, this is apparent in most of the following examples for integer values of m. | |||||
m = 1 | m = 2 | m = 3 | m = 4 | m = 5 | m = 6 |
If n1 is slightly larger than n2 and n3 then bloated forms result. The examples on the right have n1 = 40 and n2 = n3 = 10. | |||||
m = 1 | m = 2 | m = 3 | m = 4 | m = 5 | m = 6 |
Polygonal shapes are achieved with very large values of n1 and large but equal values for n2 and n3. | |||||
m = 3, n1 = 1000, n2 = 1980, n3 = 1980 |
m = 4, n1 = 1000, n2 = 1000, n3 = 1000 |
m = 5, n1 = 1000, n2 = 620, n3 = 620 |
m = 6, n1 = 1000, n2 = 390, n3 = 390 |
||
Asymmetric forms can be created by using different values for the n's. The following example have n1 = 60, n2 = 55 and n3 = 30. | |||||
m = 3 | m = 4 | m = 5 | m = 6 | ||
For non integral values of m the form is still closed for rational values. The following are example with n1 = n2 = n3 = 0.3. The max angle needs to extend from 0 to 12 pi. | |||||
m = 1/6 | m = 7/6 | m = 13/6 | m = 19/6 | ||
Smooth starfish shapes result from smaller values of n1 than the n2 and n3. The following examples have m=3 and n2 = n3 = 1.7. | |||||
n1=0.50 | n1=0.20 | n1=0.10 | n1=0.02 | ||
Constructor Summary | |
---|---|
SuperShapeGenerator()
Construct a new generator with default settings of 10 divisions over a single side between two control points. |
|
SuperShapeGenerator(int facets)
Construct a new generator with the specified number of tessellations over the side of the curve. |
Method Summary | |
---|---|
void |
generate(GeometryData data)
Generate a new set of geometry items patchd on the passed data. |
int |
getVertexCount(GeometryData data)
Get the number of vertices that this generator will create for the curve. |
void |
setCoefficients(double m,
double n1,
double n2,
double n3,
double a,
double b)
Set the coefficient values to generate a new shape. |
void |
setFacetCount(int facets)
Change the number of facets used to create this cone. |
void |
setMaxAngle(double angle)
Set the maximum angle to use for phi. |
Methods inherited from class org.j3d.geom.GeometryGenerator |
---|
createFaceNormal, createFaceNormal, createRadialNormal, createRadialNormal |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SuperShapeGenerator()
public SuperShapeGenerator(int facets)
facets
- The number of facets on a segment of the curve
java.lang.IllegalArgumentException
- The number of divisions is less than 3Method Detail |
---|
public void setFacetCount(int facets)
facets
- The number of facets on the side of the cone
java.lang.IllegalArgumentException
- The number of facets is less than 3public void setCoefficients(double m, double n1, double n2, double n3, double a, double b)
public void setMaxAngle(double angle)
angle
- The maximum angle to use in radianspublic int getVertexCount(GeometryData data) throws UnsupportedTypeException
getVertexCount
in class GeometryGenerator
data
- The data to base the calculations on
UnsupportedTypeException
- The generator cannot handle the type
of geometry you have requestedpublic void generate(GeometryData data) throws UnsupportedTypeException, InvalidArraySizeException
generate
in class GeometryGenerator
data
- The data to patch the calculations on
InvalidArraySizeException
- The array is not big enough to contain
the requested geometry
UnsupportedTypeException
- The generator cannot handle the type
of geometry you have requested
|
j3d.org Code | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |