j3d.org Code

org.j3d.geom
Class MobiusGenerator

java.lang.Object
  extended by org.j3d.geom.GeometryGenerator
      extended by org.j3d.geom.MobiusGenerator

public class MobiusGenerator
extends GeometryGenerator

A mobius strip geometry generator with specified number of divisions per strip, number of strips, position, and appearance.

The generator is used to create Mobius strip shapes as geometry. The output are coordinates as quads suitable for use in an unindexed-quad array. The number of faces (polygons) generated is derived from the number of divisions times.

When normals are calculated, they are only generated for one side of the strip. When you create the Java3D geometry from this you should make sure to set the rendering attributes to be double sided.

The algorithm was adapted from Tore Nordstrand's Math Image Gallery: http://www.uib.no/people/nfytn/mathgal.htm (This algorithm is not perfect yet: The strips are slightly out of alignment. This is easy to see with a small number of strips

The current algorithm does not have control over the diameter of the strip created. I'd like to fix it but don't know where to start yet.

Version:
$Revision: 1.2 $
Author:
Justin Couch (heavily revised version of code from unknown source)

Constructor Summary
MobiusGenerator()
          Constructs a mobius strip with 28 divisions per strip, 14 strips.
MobiusGenerator(int divisions, int strips)
          Constructs a mobius strip with number of divisions per strip and number of strips.
 
Method Summary
 float[] generateUnindexedCoordinates()
          Generates new set of points.
 void setDimensions(int divisions, int strips)
          Change the dimensions of the cone to be generated.
 
Methods inherited from class org.j3d.geom.GeometryGenerator
createFaceNormal, createFaceNormal, createRadialNormal, createRadialNormal, generate, getVertexCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MobiusGenerator

public MobiusGenerator()
Constructs a mobius strip with 28 divisions per strip, 14 strips.


MobiusGenerator

public MobiusGenerator(int divisions,
                       int strips)
Constructs a mobius strip with number of divisions per strip and number of strips.

Parameters:
divisions - The number of divisions to use
strips - The number of strips to use
Method Detail

setDimensions

public void setDimensions(int divisions,
                          int strips)
Change the dimensions of the cone to be generated. Calling this will make the points be re-calculated next time you as for geometry or normals.

Parameters:
divisions - The number of divisions to use
strips - The number of strips to use

generateUnindexedCoordinates

public float[] generateUnindexedCoordinates()
Generates new set of points. If the dimensions have not changed since the last call, the identical array will be returned. Note that you should make a copy of this if you intend to call this method more than once as it will replace the old values with the new ones and not reallocate the array.

Returns:
An array of points representing the geometry vertices

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org