|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object vclip.ConvexPolyhedron
A convex polyhedron.
Constructor Summary | |
ConvexPolyhedron()
Creates an empty ConvexPolyhedron, which should then be initialized (such as with a call to scan ). |
|
ConvexPolyhedron(double[] coords,
int[][] faceIndices)
Constructs a polyhedron given a list of vertices and a list of face indices. |
|
ConvexPolyhedron(javax.vecmath.Point3d[] vlist,
int[][] faceIndices)
Constructs a polyhedron given a list of vertices and a list of face indices. |
|
ConvexPolyhedron(java.io.Reader reader,
boolean namedFormat)
Constructs a ConvexPolyhedron by reading information from the supplied reader. |
|
ConvexPolyhedron(java.io.StreamTokenizer stok,
boolean namedFormat)
Constructs a ConvexPolyhedron by reading information from a StreamTokenizer. |
Method Summary | |
static ConvexPolyhedron |
createBox(double wx,
double wy,
double wz)
|
static ConvexPolyhedron |
createCone(double rtop,
double rbot,
double h,
int nsides)
|
static ConvexPolyhedron |
createCylinder(double r,
double h,
int nsides)
|
static ConvexPolyhedron |
createPrism(double[] xy,
double h)
|
static ConvexPolyhedron |
createPrism(double[] xyTop,
double[] xyBot,
double h)
|
static ConvexPolyhedron |
createRoundedCylinder(double r,
double h,
int nslices)
|
static ConvexPolyhedron |
createSphere(double r,
int nslices)
|
Feature |
findFeature(java.lang.String name)
|
Edge |
getEdge(int vidx1,
int vidx2)
|
Edge[] |
getEdges()
Returns the edge features for this polyhedron. |
Face |
getFace(int idx)
|
Face[] |
getFaces()
Returns the face features for this polyhedron. |
Vertex |
getVert(int idx)
|
Vertex[] |
getVerts()
Returns the vertex features for this polyhedron. |
void |
hideEdges(int[] elist)
|
void |
hideFaces(int[] flist)
|
void |
hidePrismFace(int fi)
|
void |
hideVerts(int[] vlist)
|
int |
numFeatures()
Returns the total number of features (vertices, edges, faces) on this polyhedron. |
void |
scan(java.io.Reader reader)
Sets the polyhedron using information obtained from a reader. |
void |
scan(java.io.StreamTokenizer stok)
Sets the polyhedron using information obtained from a StreamTokenizer. |
void |
scanNamedFormat(java.io.Reader reader)
Sets the polyhedron using information obtained from a reader. |
void |
scanNamedFormat(java.io.StreamTokenizer stok)
Sets the polyhedron using information obtained from a StreamTokenizer. |
void |
set(double[] coords,
int[][] faceIndices)
Sets this polyhedron given a list of vertices and a list of face indices. |
void |
set(javax.vecmath.Point3d[] vlist,
int[][] faceIndices)
Sets this polyhedron given a list of vertices and a list of face indices. |
java.lang.String |
sprintf()
Outputs a string representation of this polyhedron, using the format used by scan(Reader) . |
java.lang.String |
sprintfNamedFormat()
Outputs a string representation of this polyhedron, using the format used by scanNamedFormat(Reader) . |
java.lang.String |
toString()
Generates a string representation of this polyhedron, using sprintfNamedFormat() . |
double |
vclip(ClosestPointPair cpair,
ConvexPolyhedron poly2,
javax.vecmath.Matrix4d X12,
javax.vecmath.Matrix4d X21)
Computes the distance, along with the closest points and features, between this polyhedron and a second one. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ConvexPolyhedron()
scan
).
public ConvexPolyhedron(javax.vecmath.Point3d[] vlist, int[][] faceIndices)
vlist
- vertices for the polyhedronfaceIndices
- face index arrays
java.lang.IllegalArgumentException
- if the vertex and face
information does not describe a proper convex polyhedronpublic ConvexPolyhedron(double[] coords, int[][] faceIndices)
coords
- coordinates of the polyhedron vertices,
giving the x, y, and z values of each vertex, in order.
The length of this array will be three times
the number of vertices.faceIndices
- face index arrays
java.lang.IllegalArgumentException
- if the vertex and face
information does not describe a proper convex polyhedronpublic ConvexPolyhedron(java.io.Reader reader, boolean namedFormat) throws java.io.IOException
reader
- supplies the information used to define
the polyhedron.namedFormat
- if true
, then the polyhedron
will be read using the named format used by
scanNamedFormat
.
Otherwise, the .obj
format of
scan
will be used
java.io.IOException
- if an I/O or format error occuredscanNamedFormat(Reader)
,
scan(Reader)
public ConvexPolyhedron(java.io.StreamTokenizer stok, boolean namedFormat) throws java.io.IOException
stok
- supplies the information used to define
the polyhedron.namedFormat
- if true
, then the polyhedron
will be read using the named format used by
scanNamedFormat
.
Otherwise, the .obj
format of
scan
will be used
java.io.IOException
- if an I/O or format error occuredscanNamedFormat(Reader)
,
scan(Reader)
Method Detail |
public Feature findFeature(java.lang.String name)
public void set(javax.vecmath.Point3d[] vlist, int[][] faceIndices)
vlist
- vertices for the polyhedronfaceIndices
- face index arrays
java.lang.IllegalArgumentException
- if the vertex and face
information does not describe a proper convex polyhedronpublic void set(double[] coords, int[][] faceIndices)
coords
- coordinates of the polyhedron vertices,
giving the x, y, and z values of each vertex, in order.
The length of this array will be three times
the number of vertices.faceIndices
- face index arrays
java.lang.IllegalArgumentException
- if the vertex and face
information does not describe a proper convex polyhedronpublic void scanNamedFormat(java.io.Reader reader) throws java.io.IOException
First, the vertices of the polyhedra are listed, each
with a name, followed by three numbers
giving the coordinates. If the vertex name is given as
-
, then a name of the form
v
n will be automatically generated,
where n denotes the number of the vertex. The
character *
is used to terminate the vertex
list.
Second, the faces are listed, each with a name,
followed by a list (on the same
line) of the names of the vertices (in counter-clockwise
order). If the face name is given as
-
, then a name of the form
f
n will be generated, where n
is the number of the face. The
character *
is used to terminate the face
list.
A simple example defining a tetrahedron is
origin 0 0 0 x 1 0 0 y 0 1 0 z 0 0 1 * xy origin y x yz origin z y zx origin x z base x y z
Using automatic naming, the same example would look like
- 0 0 0 - 1 0 0 - 0 1 0 - 0 0 1 * - v0 v2 v1 - v0 v3 v2 - v0 v1 v3 - v1 v2 v3
reader
- supplies the information used to describe
the polyhedron.
java.io.IOException
- if an I/O or format error occuredpublic void scanNamedFormat(java.io.StreamTokenizer stok) throws java.io.IOException
scanNamedFormat(Reader)
.
stok
- supplies the information used to describe
the polyhedron.
java.io.IOException
- if an I/O or format error occuredscanNamedFormat(Reader)
public void scan(java.io.StreamTokenizer stok) throws java.io.IOException
scan(Reader)
.
stok
- supplies the information used to describe
the polyhedron.
java.io.IOException
- if an I/O or format error occuredscan(Reader)
public void scan(java.io.Reader reader) throws java.io.IOException
.obj
format:
First, the vertices of the polyhedra are listed, each
preceded with the character v
,
followed by three numbers
giving the coordinates.
Second, the faces are listed, each
preceded by the character f
,
followed by a counter-clockwise list of the vertex indices.
Each index
refers to the vertex's location within the
vertex list, with the first vertex numbered as 1
.
The keyword end
is used to terminate the face list.
A simple example defining a tetrahedron is
v 0.0 0.0 0.0 v 1.0 0.0 0.0 v 0.0 1.0 0.0 v 0.0 0.0 1.0 f 0 2 1 f 0 3 2 f 0 1 3 f 1 2 3 end
reader
- supplies the information used to describe
the polyhedron.
java.io.IOException
- if an I/O or format error occuredpublic final Vertex[] getVerts()
public final Vertex getVert(int idx)
public final Edge[] getEdges()
public final Edge getEdge(int vidx1, int vidx2)
public final Face[] getFaces()
public final Face getFace(int idx)
public final int numFeatures()
public java.lang.String sprintf()
scan(Reader)
.
.obj
representation of this polyhedronpublic java.lang.String sprintfNamedFormat()
scanNamedFormat(Reader)
.
public java.lang.String toString()
sprintfNamedFormat()
.
sprintfNamedFormat()
public double vclip(ClosestPointPair cpair, ConvexPolyhedron poly2, javax.vecmath.Matrix4d X12, javax.vecmath.Matrix4d X21)
cpair
parameter is used to
return the closest point and feature information. To
facilitate fast computation, this parameter should also be
initialized with a guess of the closest features between
the two polyhedra (using ClosestPointPair.setFeatures
). This guess is usually just the
features that were determined the last time vclip
was called for this pair of polyhedra. If no feature
guess is given, then vclip
starts with the
first vertex of each polyhedron.
If the two polyhedra are interpenetrating, the routine returns a non-positive number giving a roughstimate of the interpenetration distance. The closest feature information in this case is not particularly useful.
cpair
- returns closest point pair information, and
supplies an initial guess of the closest features.poly2
- the second polyhedronX12
- spatial transform from the reference frame of the first
polyhedron to the reference frame of the secondX21
- spatial transform from the reference frame of the
second polyhedron to the reference frame of the first
public static ConvexPolyhedron createBox(double wx, double wy, double wz)
public static ConvexPolyhedron createCylinder(double r, double h, int nsides)
public static ConvexPolyhedron createSphere(double r, int nslices)
public static ConvexPolyhedron createRoundedCylinder(double r, double h, int nslices)
public static ConvexPolyhedron createCone(double rtop, double rbot, double h, int nsides)
public static ConvexPolyhedron createPrism(double[] xy, double h)
public static ConvexPolyhedron createPrism(double[] xyTop, double[] xyBot, double h)
public void hideVerts(int[] vlist)
public void hideFaces(int[] flist)
public void hideEdges(int[] elist)
public void hidePrismFace(int fi)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |