use of maspack.matrix.Point3d in project artisynth_core by artisynth.
the class CPDTest method main.
public static void main(String[] args) {
AffineTransform3d trans = new AffineTransform3d();
RotationMatrix3d R = new RotationMatrix3d(0.7605, -0.6307, 0.1541, 0.6485, 0.7263, -0.2279, 0.0318, 0.2733, 0.9614);
double s = 2.7;
trans.setA(R, new Vector3d(s, s, s), new Vector3d(0, 0, 0));
trans.setTranslation(new Vector3d(1, 2, 3));
Point3d[] X = get3DFish();
int N = X.length;
int M = N - 20;
Point3d[] Y = new Point3d[M];
Point3d[] out = new Point3d[M];
for (int i = 0; i < N; i++) {
if (i < M) {
Y[i] = new Point3d(X[i]);
out[i] = new Point3d();
}
X[i].transform(trans);
}
double w = 0.01;
double lambda = 0.1;
double beta2 = 3.5;
CPD.verbose = true;
ScaledRigidTransform3d rigidT = CPD.rigid(X, Y, w, 1e-10, 100, true, out);
AffineTransform3d affT = CPD.affine(X, Y, w, 1e-10, 100, out);
CPD.coherent(X, Y, lambda, beta2, w, 1e-10, 100, out);
System.out.println("Original: \n" + trans.toString());
System.out.println("Rigid Computed: \n" + rigidT.toString());
System.out.println("Affine Computed: \n" + affT.toString());
for (int i = 0; i < M; i++) {
System.out.println(X[i].toString() + "\n" + out[i].toString() + "\n");
}
}
use of maspack.matrix.Point3d in project artisynth_core by artisynth.
the class CPDTest method get3DFish.
public static Point3d[] get3DFish() {
final double[][] fish = { { -0.91542, -0.16535, 0.00000 }, { -0.89051, -0.10213, 0.00000 }, { -0.85730, -0.10213, 0.00000 }, { -0.82408, -0.14955, 0.00000 }, { -0.87390, -0.19696, 0.00000 }, { -0.92372, -0.16535, 0.00000 }, { -1.06488, -0.29180, 0.00000 }, { -1.02336, -0.16535, 0.00000 }, { -0.98185, -0.05471, 0.00000 }, { -0.95694, 0.02432, 0.00000 }, { -0.91542, 0.11915, 0.00000 }, { -0.88221, 0.18237, 0.00000 }, { -0.80747, 0.26140, 0.00000 }, { -0.75765, 0.34043, 0.00000 }, { -0.67462, 0.46687, 0.00000 }, { -0.58328, 0.54590, 0.00000 }, { -0.51686, 0.60912, 0.00000 }, { -0.40061, 0.70396, 0.00000 }, { -0.33418, 0.81460, 0.00000 }, { -0.26775, 1.16232, 0.00000 }, { -0.20133, 1.46262, 0.00000 }, { -0.15151, 1.76293, 0.00000 }, { -0.14320, 1.88938, 0.00000 }, { -0.11829, 2.11065, 0.00000 }, { -0.10169, 1.96840, 0.00000 }, { -0.09338, 1.74713, 0.00000 }, { -0.09338, 1.54165, 0.00000 }, { -0.08508, 1.30457, 0.00000 }, { -0.09338, 1.11490, 0.00000 }, { -0.07678, 0.90943, 0.00000 }, { -0.07678, 0.71976, 0.00000 }, { -0.04356, 0.56171, 0.00000 }, { -0.03526, 0.48268, 0.00000 }, { 0.04777, 0.40365, 0.00000 }, { 0.11420, 0.34043, 0.00000 }, { 0.16402, 0.27721, 0.00000 }, { 0.22215, 0.21398, 0.00000 }, { 0.29688, 0.10334, 0.00000 }, { 0.36330, -0.00729, 0.00000 }, { 0.44634, -0.08632, 0.00000 }, { 0.50446, -0.05471, 0.00000 }, { 0.57089, 0.04012, 0.00000 }, { 0.60410, 0.18237, 0.00000 }, { 0.67053, 0.38784, 0.00000 }, { 0.72865, 0.62493, 0.00000 }, { 0.81999, 0.67235, 0.00000 }, { 0.90302, 0.76718, 0.00000 }, { 0.88642, 0.62493, 0.00000 }, { 0.86981, 0.46687, 0.00000 }, { 0.86151, 0.26140, 0.00000 }, { 0.83660, 0.10334, 0.00000 }, { 0.84490, -0.13374, 0.00000 }, { 0.84490, -0.30760, 0.00000 }, { 0.84490, -0.52888, 0.00000 }, { 0.87811, -0.73435, 0.00000 }, { 0.92794, -0.89241, 0.00000 }, { 0.98606, -1.00305, 0.00000 }, { 1.03588, -1.12949, 0.00000 }, { 1.04418, -1.20852, 0.00000 }, { 0.96945, -1.14530, 0.00000 }, { 0.88642, -1.05046, 0.00000 }, { 0.79508, -0.97144, 0.00000 }, { 0.68714, -0.92402, 0.00000 }, { 0.59580, -0.82919, 0.00000 }, { 0.53768, -0.75016, 0.00000 }, { 0.47125, -0.63952, 0.00000 }, { 0.41312, -0.57630, 0.00000 }, { 0.28857, -0.52888, 0.00000 }, { 0.18893, -0.46566, 0.00000 }, { 0.08929, -0.46566, 0.00000 }, { -0.03526, -0.49727, 0.00000 }, { -0.08508, -0.49727, 0.00000 }, { -0.00205, -0.57630, 0.00000 }, { 0.09760, -0.65532, 0.00000 }, { 0.17233, -0.68694, 0.00000 }, { 0.26366, -0.73435, 0.00000 }, { 0.21384, -0.73435, 0.00000 }, { 0.03947, -0.73435, 0.00000 }, { -0.15151, -0.73435, 0.00000 }, { -0.26775, -0.71855, 0.00000 }, { -0.40061, -0.67113, 0.00000 }, { -0.46704, -0.60791, 0.00000 }, { -0.55837, -0.52888, 0.00000 }, { -0.59989, -0.51307, 0.00000 }, { -0.77426, -0.46566, 0.00000 }, { -0.89051, -0.48146, 0.00000 }, { -0.98185, -0.43405, 0.00000 }, { -1.03997, -0.37082, 0.00000 }, { -1.05658, -0.29180, 0.00000 }, { -0.05048, -0.75806, 0.00000 }, { 0.09967, -0.75806, 0.00000 } };
Point3d[] fishPts = new Point3d[fish.length];
for (int i = 0; i < fish.length; i++) {
fishPts[i] = new Point3d(fish[i]);
}
return fishPts;
}
use of maspack.matrix.Point3d in project artisynth_core by artisynth.
the class CSG method main.
public static void main(String[] args) {
CSG csg = new CSG();
csg.doSphereTest(1, 1, 1);
csg.doCubeTest(new Point3d(0.75, 0.75, 0.75));
doObbTest();
if (args.length == 2) {
csg.doDiceTest(args[0], args[1]);
}
}
use of maspack.matrix.Point3d in project artisynth_core by artisynth.
the class ConstrainedTranslator3d method checkComponentSelection.
private boolean checkComponentSelection(Line ray, double distancePerPixel) {
Line draggerRay = new Line(ray);
draggerRay.inverseTransform(myXDraggerToWorld);
double lineDist = 5 * distancePerPixel;
double l;
Point3d p = new Point3d();
// check axes first
l = xAxis.nearestPoint(p, draggerRay);
if (l >= -mySize && l <= mySize) {
if (draggerRay.distance(p) < lineDist) {
return true;
}
}
l = yAxis.nearestPoint(p, draggerRay);
if (l >= -mySize && l <= mySize) {
if (draggerRay.distance(p) < lineDist) {
return true;
}
}
l = zAxis.nearestPoint(p, draggerRay);
if (l >= -mySize && l <= mySize) {
if (draggerRay.distance(p) < lineDist) {
return true;
}
}
return false;
}
use of maspack.matrix.Point3d in project artisynth_core by artisynth.
the class MeshRendererBase method addPositions.
protected void addPositions(RenderObject r, MeshBase mesh) {
boolean useRenderData = mesh.isRenderBuffered() && !mesh.isFixed();
for (int i = 0; i < mesh.numVertices(); i++) {
Vertex3d vtx = mesh.getVertex(i);
Point3d pos = useRenderData ? vtx.myRenderPnt : vtx.pnt;
r.addPosition((float) pos.x, (float) pos.y, (float) pos.z);
}
}
Aggregations