use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.
the class MeshFactory method createQuadHemisphere.
public static PolygonalMesh createQuadHemisphere(double r, int nslices, int nlevels, double x, double y, double z) {
double tol = computeSphericalPointTolerance(r, 2 * Math.PI, Math.PI, nslices, nlevels);
PolygonalMesh mesh = new PolygonalMesh();
VertexMap vtxMap = new VertexMap(tol);
RigidTransform3d XLM = new RigidTransform3d(x, y, z);
addQuadSphericalSection(mesh, r, Math.PI, Math.PI / 2, nslices, nlevels, XLM, vtxMap);
return mesh;
}
use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.
the class MeshFactory method createQuadExtendedTorus.
/**
* Creates a quad extended torus mesh in the x-y plane. An extended torus
* is a torus with straight sections added in the middle, giving a
* shape similar to a chain link. The straight sections are parallel
* to the x-axis.
*
* @param rmajor major radius of the torus
* @param rminor minor radius of the torus
* @param xlen length of the straight sections
* @param nmajor number of slices along the major radius
* @param nminor number of slices along the minor radius
*/
public static PolygonalMesh createQuadExtendedTorus(double rmajor, double rminor, double xlen, int nmajor, int nminor) {
double tol = computeToroidalTolerance(rmajor, rminor, 2 * Math.PI, nmajor, nminor);
VertexMap vtxMap = new VertexMap(tol);
PolygonalMesh mesh = new PolygonalMesh();
RigidTransform3d XLM = new RigidTransform3d();
XLM.p.set(xlen / 2, 0, 0);
XLM.R.setRpy(-Math.PI / 2, 0, 0);
addQuadToroidalSection(mesh, rmajor, rminor, Math.PI, nmajor, nminor, XLM, vtxMap);
XLM.p.set(-xlen / 2, 0, 0);
XLM.R.setRpy(Math.PI / 2, 0, 0);
addQuadToroidalSection(mesh, rmajor, rminor, Math.PI, nmajor, nminor, XLM, vtxMap);
double outerChordLen = 2 * (rmajor + rminor) * Math.sin(Math.PI / (nmajor));
int nx = (int) Math.ceil(xlen / outerChordLen);
XLM.p.set(0, rmajor, 0);
XLM.R.setRpy(0, Math.PI / 2, 0);
addQuadCylindricalSection(mesh, rminor, xlen, 2 * Math.PI, nx, nminor, /*outward=*/
true, XLM, vtxMap);
XLM.p.set(0, -rmajor, 0);
XLM.R.setRpy(0, Math.PI / 2, 0);
addQuadCylindricalSection(mesh, rminor, xlen, 2 * Math.PI, nx, nminor, /*outward=*/
true, XLM, vtxMap);
return mesh;
}
use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.
the class MeshFactory method createQuadBoxNew.
public static PolygonalMesh createQuadBoxNew(double wx, double wy, double wz, Point3d center, int nx, int ny, int nz) {
double tol = Math.min(wx / nx, wy / ny);
tol = Math.min(tol, wz / nz);
VertexMap vtxMap = new VertexMap(tol);
PolygonalMesh mesh = new PolygonalMesh();
RigidTransform3d XLM = new RigidTransform3d();
XLM.p.set(center);
XLM.p.z = center.z + wz / 2;
addQuadRectangle(mesh, wx, wy, nx, ny, XLM, vtxMap);
XLM.p.z = center.z - wz / 2;
XLM.R.set(1, 0, 0, 0, -1, 0, 0, 0, -1);
addQuadRectangle(mesh, wx, wy, nx, ny, XLM, vtxMap);
XLM.p.z = 0;
XLM.p.x = center.x + wx / 2;
XLM.R.set(0, 0, -1, 0, 1, 0, 1, 0, 0);
addQuadRectangle(mesh, wz, wy, nz, ny, XLM, vtxMap);
XLM.p.x = center.x - wx / 2;
XLM.R.set(0, 0, 1, 0, 1, 0, -1, 0, 0);
addQuadRectangle(mesh, wz, wy, nz, ny, XLM, vtxMap);
XLM.p.x = 0;
XLM.p.y = center.y + wy / 2;
XLM.R.set(1, 0, 0, 0, 0, -1, 0, 1, 0);
addQuadRectangle(mesh, wz, wy, nz, ny, XLM, vtxMap);
XLM.p.y = center.y - wy / 2;
XLM.R.set(1, 0, 0, 0, 0, 1, 0, -1, 0);
addQuadRectangle(mesh, wz, wy, nz, ny, XLM, vtxMap);
return mesh;
}
use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.
the class MeshFactory method createQuadSphere.
public static PolygonalMesh createQuadSphere(double r, int nslices, int nlevels, double x, double y, double z, boolean addTextureCoords) {
double tol = computeSphericalPointTolerance(r, 2 * Math.PI, Math.PI, nslices, nlevels);
PolygonalMesh mesh = new PolygonalMesh();
VertexMap vtxMap = new VertexMap(tol);
RigidTransform3d XLM = new RigidTransform3d(x, y, z);
addQuadSphericalSection(mesh, r, Math.PI, Math.PI, nslices, nlevels, XLM, vtxMap);
if (addTextureCoords) {
Point3d origin = new Point3d(x, y, z);
computeTextureCoordsForSphere(mesh, origin, r, tol);
}
return mesh;
}
use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.
the class BVFeatureQueryTest method nearestVertexAndEdgeTest.
private void nearestVertexAndEdgeTest(MeshBase mesh) {
// NearestFeatureQuery query = new NearestFeatureQuery();
double inf = Double.POSITIVE_INFINITY;
Point3d max = new Point3d(-inf, -inf, -inf);
Point3d min = new Point3d(inf, inf, inf);
Point3d center = new Point3d();
Point3d widths = new Point3d();
mesh.updateBounds(min, max);
center.add(min, max);
center.scale(0.5);
widths.sub(max, min);
widths.scale(0.5);
double diameter = max.distance(min);
RigidTransform3d X = new RigidTransform3d();
OBBTree obbTree = new OBBTree(mesh, 2);
AABBTree aabbTree = new AABBTree(mesh, 2, 0.001 * diameter);
nearestVertexAndEdge(mesh, obbTree, X, center, diameter);
nearestVertexAndEdge(mesh, aabbTree, X, center, diameter);
X.setRandom();
nearestVertexAndEdge(mesh, obbTree, X, center, diameter);
// aabbTree.print();
nearestVertexAndEdge(mesh, aabbTree, X, center, diameter);
X.setRandom();
nearestVertexAndEdge(mesh, obbTree, X, center, diameter);
nearestVertexAndEdge(mesh, aabbTree, X, center, diameter);
X.setRandom();
nearestVertexAndEdge(mesh, obbTree, X, center, diameter);
nearestVertexAndEdge(mesh, aabbTree, X, center, diameter);
}
Aggregations