public class MeshUtils
extends java.lang.Object
Constructor and Description |
---|
MeshUtils() |
Modifier and Type | Method and Description |
---|---|
static double[] |
centerPoints(double[] points,
Vertex center)
Create an array containing the given three dimensional points moved to be
centered around the given vertex.
|
static double[] |
createCircle(double radius,
int samples)
Creates a series of points which lie evenly spaced on the edge of a
circle on the XZ plane defined by the arguments.
|
static float[] |
createCircle(float radius,
int samples)
Creates a series of points which lie evenly spaced on the edge of a
circle on the XZ plane defined by the arguments.
|
static double[] |
createRectangularPrism(double lengthX,
double lengthY,
double lengthZ)
Create a list of 3D points forming the vertices of a rectangular prism
with the given side lengths.
|
static org.eclipse.emf.common.util.EList<Triangle> |
createRectangularPrismMesh(double[] points)
Create a list of triangles which form a box between the eight input
points.
|
static double[] |
createSemiCircle(double radius,
int samples,
boolean top)
Creates a series of points which lie evenly spaced on the edge of a
semicircle on the XY plane defined by the arguments.
|
static double[] |
createTube(double height,
double innerRadius,
double radius,
int resolution,
int segments)
Create the points which define a tube.
|
static org.eclipse.emf.common.util.EList<Triangle> |
createTubeMesh(double[] points,
int resolution,
int segments)
Create a list of triangles that define a tube.
|
static double[] |
rotatePoints(double[] points,
double rotationX,
double rotationY,
double rotationZ)
Rotate the given points around the x, y, and z axes by the given amount.
|
static double[] |
rotatePointsAboutAxis(double[] points,
Vertex axis,
double magnitude)
Rotate the given set of three dimensional points about the axis beginning
at the origin and ending at the given vertex.
|
public static double[] centerPoints(double[] points, Vertex center)
points
- The coordinates for the original points, given in the format
x1, y1, z1, x2, y2, z2, x3... centered around the origin.center
- The vertex around which the coordinates will be moved.public static double[] createCircle(double radius, int samples)
radius
- The circle's radiussamples
- The number of points to createpublic static float[] createCircle(float radius, int samples)
radius
- The circle's radiussamples
- The number of points to createpublic static double[] createRectangularPrism(double lengthX, double lengthY, double lengthZ)
lengthX
- The box's x side length.lengthY
- The box's y side length.lengthZ
- The box's z side length.public static org.eclipse.emf.common.util.EList<Triangle> createRectangularPrismMesh(double[] points)
points
- A length 24 array containing the eight points defining the
corners of the mesh, specified in the order x1, y1, z1, x2,
y2, z2, x3...public static double[] createSemiCircle(double radius, int samples, boolean top)
radius
- The circle's radiussamples
- The number of points to createtop
- Whether or not to render the top half of a circle. If true,
the top half of the circle will be rendered. If false, the
bottom half of the circle will be rendered.public static double[] createTube(double height, double innerRadius, double radius, int resolution, int segments)
height
- How tall the tube will be.innerRadius
- The radius for the inner cylinder. If innerRadius is equal to
radius, there will be no inner cylinderradius
- The radius of the tube.resolution
- How many sample points will exist along the circle defining
the edges of the tube.segments
- How many sample points will be used along the cylinder's
length. The cylinder will be defined by two (or one) circles
on (segments + 1) equally spaced levels.public static org.eclipse.emf.common.util.EList<Triangle> createTubeMesh(double[] points, int resolution, int segments)
points
- The three dimensional points points defining the tube. It is
expected that each point will be specified by its three
coordinates in the order x, y, z. Points are to be ordered
such that each point lies on a circle, with the tube's shells
defined by several such circles moving up the mesh. There will
be a number of points on each circle equal to resolution and a
number of circles equal to either segments + 1 (for a thin
tube) or 2 * (segments + 1) (for a tube with some thickness
between the outer shell and the inner hole.) Each circle must
have all of its points defined before moving on to the next
circle's points. Circles must be specified in order from the
bottom of the tube to the top of one of the two cylinders,
then from bottom to top of the other cylinder. Points must be
specified in the same order around each circle, such that all
points congruent to some number X modulo the resolution all
lie on a a straight line (or two straight lines, one for each
of the two cylinders) and the ith point on the jth circle on
one cylinder is the closest point on that cylinder to the ith
point on the jth cylinder on the other cylinder. Points's
length must be equal to 3 * resolution * (segments + 1) or 6 *
resolution * (segments + 1).resolution
- The number of points defining the circles around each of the
cylinders.segments
- The number of cylindrical segments the tube's mesh is broken
into. Spublic static double[] rotatePoints(double[] points, double rotationX, double rotationY, double rotationZ)
points
- A list of coordinates for points in three dimensional space to
rotate. These are expected to be specified in the format x1,
y1, z1, x2, y2, z2, x3...rotationX
- The amount of rotation about the x axis, given in radians.rotationY
- The amount of rotation about the y axis, given in radians.rotationZ
- The amount of rotation about the z axis, given in radians.public static double[] rotatePointsAboutAxis(double[] points, Vertex axis, double magnitude)
points
- The coordinates of the points to be rotated. It is expected
that these will be given in the format x1, y1, z1, x2, y2, z2,
x3...axis
- The endpoint of the axis around which the rotation will
happen.magnitude
- The amount of rotation to apply, given in radians.