private static final float MAG = 1;
Geom.M[] translations;
- Geom.P[] points;
+ Geom.V[] points;
public Main(StlFile stlf) {
for(int i=0; i<stlf.coordArray.length; i+=3) {
- Geom.P p0 = goal.newP(stlf.coordArray[i+0].x * MAG, stlf.coordArray[i+0].y * MAG, stlf.coordArray[i+0].z * MAG);
- Geom.P p1 = goal.newP(stlf.coordArray[i+1].x * MAG, stlf.coordArray[i+1].y * MAG, stlf.coordArray[i+1].z * MAG);
- Geom.P p2 = goal.newP(stlf.coordArray[i+2].x * MAG, stlf.coordArray[i+2].y * MAG, stlf.coordArray[i+2].z * MAG);
- Geom.V n = goal.new V(stlf.normArray[i/3].x * MAG, stlf.normArray[i/3].y * MAG, stlf.normArray[i/3].z * MAG);
+ Geom.V p0 = goal.register(new Geom.P(stlf.coordArray[i+0].x * MAG, stlf.coordArray[i+0].y * MAG, stlf.coordArray[i+0].z * MAG));
+ Geom.V p1 = goal.register(new Geom.P(stlf.coordArray[i+1].x * MAG, stlf.coordArray[i+1].y * MAG, stlf.coordArray[i+1].z * MAG));
+ Geom.V p2 = goal.register(new Geom.P(stlf.coordArray[i+2].x * MAG, stlf.coordArray[i+2].y * MAG, stlf.coordArray[i+2].z * MAG));
+ Geom.Vec n = new Geom.Vec(stlf.normArray[i/3].x * MAG, stlf.normArray[i/3].y * MAG, stlf.normArray[i/3].z * MAG);
Geom.T t = goal.newT(p0, p1, p2, n);
}
// rotate to align major axis -- this probably needs to be done by a human.
- goal.transform(goal.new M(goal.new V(0, 0, 1), (float)(Math.PI/2)));
+ goal.transform(new Geom.M(new Geom.Vec(0, 0, 1), (float)(Math.PI/2)));
- float goal_width = goal.diagonal().dot(goal.new V(1, 0, 0));
- float goal_height = goal.diagonal().dot(goal.new V(0, 1, 0));
- float goal_depth = goal.diagonal().dot(goal.new V(0, 0, 1));
+ float goal_width = goal.diagonal().dot(new Geom.Vec(1, 0, 0));
+ float goal_height = goal.diagonal().dot(new Geom.Vec(0, 1, 0));
+ float goal_depth = goal.diagonal().dot(new Geom.Vec(0, 0, 1));
float width = (float)0.6;
float height = (float)0.08;
float depth = (float)0.3;
translations = new Geom.M[] {
- tile.new M(tile.new V(-(width/2), height, 0)),
- tile.new M(tile.new V( (width/2), height, 0)),
- tile.new M(tile.new V(-(width/2), -height, 0)),
- tile.new M(tile.new V( (width/2), -height, 0)),
- tile.new M(tile.new V(-(width/2), 0, depth)),
- tile.new M(tile.new V( (width/2), 0, depth)),
- tile.new M(tile.new V(-(width/2), 0, -depth)),
- tile.new M(tile.new V( (width/2), 0, -depth)),
-
- tile.new M(tile.new V( width, 0, 0)),
- tile.new M(tile.new V(-width, 0, 0)),
+ new Geom.M(new Geom.Vec(-(width/2), height, 0)),
+ new Geom.M(new Geom.Vec( (width/2), height, 0)),
+ new Geom.M(new Geom.Vec(-(width/2), -height, 0)),
+ new Geom.M(new Geom.Vec( (width/2), -height, 0)),
+ new Geom.M(new Geom.Vec(-(width/2), 0, depth)),
+ new Geom.M(new Geom.Vec( (width/2), 0, depth)),
+ new Geom.M(new Geom.Vec(-(width/2), 0, -depth)),
+ new Geom.M(new Geom.Vec( (width/2), 0, -depth)),
+
+ new Geom.M(new Geom.Vec( width, 0, 0)),
+ new Geom.M(new Geom.Vec(-width, 0, 0)),
/*
- tile.new M(tile.new V( 0, 0, depth)),
- tile.new M(tile.new V( 0, 0, -depth)),
+ new Geom.M(new Geom.Vec( 0, 0, depth)),
+ new Geom.M(new Geom.Vec( 0, 0, -depth)),
*/
};
- Geom.P ltf = tile.newP(-(width/2), (height/2), (depth/2));
- Geom.P mtf = tile.newP( 0.0, (height/2), (depth/2));
- Geom.P rtf = tile.newP( (width/2), (height/2), (depth/2));
- Geom.P ltn = tile.newP(-(width/2), (height/2), -(depth/2));
- Geom.P mtn = tile.newP( 0.0, (height/2), -(depth/2));
- Geom.P rtn = tile.newP( (width/2), (height/2), -(depth/2));
- Geom.P lbf = tile.newP(-(width/2), -(height/2), (depth/2));
- Geom.P mbf = tile.newP( 0.0, -(height/2), (depth/2));
- Geom.P rbf = tile.newP( (width/2), -(height/2), (depth/2));
- Geom.P lbn = tile.newP(-(width/2), -(height/2), -(depth/2));
- Geom.P mbn = tile.newP( 0.0, -(height/2), -(depth/2));
- Geom.P rbn = tile.newP( (width/2), -(height/2), -(depth/2));
+ Geom.V ltf = tile.register(new Geom.P(-(width/2), (height/2), (depth/2)));
+ Geom.V mtf = tile.register(new Geom.P( 0.0, (height/2), (depth/2)));
+ Geom.V rtf = tile.register(new Geom.P( (width/2), (height/2), (depth/2)));
+ Geom.V ltn = tile.register(new Geom.P(-(width/2), (height/2), -(depth/2)));
+ Geom.V mtn = tile.register(new Geom.P( 0.0, (height/2), -(depth/2)));
+ Geom.V rtn = tile.register(new Geom.P( (width/2), (height/2), -(depth/2)));
+ Geom.V lbf = tile.register(new Geom.P(-(width/2), -(height/2), (depth/2)));
+ Geom.V mbf = tile.register(new Geom.P( 0.0, -(height/2), (depth/2)));
+ Geom.V rbf = tile.register(new Geom.P( (width/2), -(height/2), (depth/2)));
+ Geom.V lbn = tile.register(new Geom.P(-(width/2), -(height/2), -(depth/2)));
+ Geom.V mbn = tile.register(new Geom.P( 0.0, -(height/2), -(depth/2)));
+ Geom.V rbn = tile.register(new Geom.P( (width/2), -(height/2), -(depth/2)));
- points = new Geom.P[] {
+ points = new Geom.V[] {
ltf,
mtf,
rtf,
for(Geom.T t2 : tile) {
if (t1==t2) continue;
- if ((t1.p1().times(m).minus(t2.p1()).mag() < Geom.EPSILON) &&
- (t1.p2().times(m).minus(t2.p3()).mag() < Geom.EPSILON) &&
- (t1.p3().times(m).minus(t2.p2()).mag() < Geom.EPSILON)) {
+ if ((t1.p1().p.times(m).minus(t2.p1().p).mag() < Geom.EPSILON) &&
+ (t1.p2().p.times(m).minus(t2.p3().p).mag() < Geom.EPSILON) &&
+ (t1.p3().p.times(m).minus(t2.p2().p).mag() < Geom.EPSILON)) {
t1.e1().bind(t2.e3().pair);
t1.e2().bind(t2.e2().pair);
t1.e3().bind(t2.e1().pair);
}
- if ((t1.p2().times(m).minus(t2.p1()).mag() < Geom.EPSILON) &&
- (t1.p3().times(m).minus(t2.p3()).mag() < Geom.EPSILON) &&
- (t1.p1().times(m).minus(t2.p2()).mag() < Geom.EPSILON)) {
+ if ((t1.p2().p.times(m).minus(t2.p1().p).mag() < Geom.EPSILON) &&
+ (t1.p3().p.times(m).minus(t2.p3().p).mag() < Geom.EPSILON) &&
+ (t1.p1().p.times(m).minus(t2.p2().p).mag() < Geom.EPSILON)) {
t1.e2().bind(t2.e3().pair);
t1.e3().bind(t2.e2().pair);
t1.e1().bind(t2.e1().pair);
}
- if ((t1.p3().times(m).minus(t2.p1()).mag() < Geom.EPSILON) &&
- (t1.p1().times(m).minus(t2.p3()).mag() < Geom.EPSILON) &&
- (t1.p2().times(m).minus(t2.p2()).mag() < Geom.EPSILON)) {
+ if ((t1.p3().p.times(m).minus(t2.p1().p).mag() < Geom.EPSILON) &&
+ (t1.p1().p.times(m).minus(t2.p3().p).mag() < Geom.EPSILON) &&
+ (t1.p2().p.times(m).minus(t2.p2().p).mag() < Geom.EPSILON)) {
t1.e3().bind(t2.e3().pair);
t1.e1().bind(t2.e2().pair);
t1.e2().bind(t2.e1().pair);
}
}
- //xGeom.P mid = lbf.getE(mbn).shatter();
+ //xGeom.V mid = lbf.getE(mbn).shatter();
// rescale to match volume
float factor = (float)Math.pow(tile.volume() / goal.volume(), 1.0/3.0);
- goal.transform(goal.new M(factor));
+ goal.transform(new Geom.M(factor));
// translate to match centroid
- goal.transform(goal.new M(tile.centroid().minus(goal.centroid())));
+ goal.transform(new Geom.M(tile.centroid().minus(goal.centroid())));
//tx.e2.shatter();
//tx.e3.shatter();
tile.bind();
- //mid.move(tile.new V((float)0,0,(float)-0.05));
- //ltn.move(tile.new V((float)0,0,(float)-0.05));
+ //mid.move(new Geom.Vec((float)0,0,(float)-0.05));
+ //ltn.move(new Geom.Vec((float)0,0,(float)-0.05));
- //mtf.move(tile.new V(0, (float)-0.05, (float)0.05));
+ //mtf.move(new Geom.Vec(0, (float)-0.05, (float)0.05));
System.out.println("tile volume: " + tile.volume());
Random random = new Random();
public synchronized void breakit() {
- if (verts > 40) return;
+ if (verts > 300) return;
//double min = (tile.avgedge/tile.numedges)*(1+(4/(double)verts));
//if (verts>0 && tile.es.peek().length() < min) return;
PriorityQueue<Geom.E> es = new PriorityQueue<Geom.E>();
for(Geom.E e : tile.es) es.add(e);
- for(int i=0; i<1; i++) {
+ for(int i=0; i<10; i++) {
Geom.E e = es.poll();
verts++;
System.out.println("shatter " + e);
}
}
- public synchronized void rand(double temperature, Geom.P p) {
+ public synchronized void rand(double temperature, Geom.V p) {
double tile_score = tile.score();
double goal_score = goal.score();
r1 = r1 - (float)Math.floor(r1);
r1 = r1 * (float)0.01;
r1 = r1 - (float)0.005;
- Geom.V v = p.watchback().minus(p).norm().times(r1);
+ Geom.Vec v = p.watchback().p.minus(p.p).norm().times(r1);
//v = p.norm().times(v.dot(p.norm()));
boolean aspect = false;//(Math.abs(random.nextInt()) % 100) <= 2;
- Geom.M old_tile_aspect = goal.aspect;
+ Geom.M old_tile_aspect = null;//goal.aspect;
boolean good = true;
if (aspect) {
+ /*
v = v.times(10);
- tile.aspect = tile.new M(tile.aspect.a / (v.x+1), tile.aspect.f / (v.y+1), tile.aspect.k / (v.z+1));
- tile.invaspect = tile.new M(1/tile.aspect.a, 1/tile.aspect.f, 1/tile.aspect.k);
+ tile.aspect = new Geom.M(tile.aspect.a / (v.x+1), tile.aspect.f / (v.y+1), tile.aspect.k / (v.z+1));
+ tile.invaspect = new Geom.M(1/tile.aspect.a, 1/tile.aspect.f, 1/tile.aspect.k);
goal.rescore();
tile.rescore();
+ */
} else {
good = p.move(v);
}
if (aspect) System.out.println("aspect " + v);
} else {
if (aspect) {
- tile.aspect = old_tile_aspect;
- tile.invaspect = tile.new M(1/tile.aspect.a, 1/tile.aspect.f, 1/tile.aspect.k);
+ //tile.aspect = old_tile_aspect;
+ //tile.invaspect = new Geom.M(1/tile.aspect.a, 1/tile.aspect.f, 1/tile.aspect.k);
goal.rescore();
tile.rescore();
} else {
//if (v1.z==0 && v1.y==0) continue;
i++;
if (i != 1 /*&& i!=4*/) continue;
- Geom.P p = tile.newP(0, 0, 0).times(m);
- Geom.V v = tile.new V(p.x, p.y, p.z);
+ Geom.P p = new Geom.P(0, 0, 0).times(m);
+ Geom.Vec v = new Geom.Vec(p.x, p.y, p.z);
v = v.times((float)1.04);
gl.glTranslatef(v.x, v.y, v.z);
draw(gl, false, tile);
gl.glEnd();
} else {
gl.glBegin(GL.GL_LINES);
- t.e1().p1.glVertex(gl);
- t.e1().p2.glVertex(gl);
- t.e2().p1.glVertex(gl);
- t.e2().p2.glVertex(gl);
- t.e3().p1.glVertex(gl);
- t.e3().p2.glVertex(gl);
+ t.e1().p1.p.glVertex(gl);
+ t.e1().p2.p.glVertex(gl);
+ t.e2().p1.p.glVertex(gl);
+ t.e2().p2.p.glVertex(gl);
+ t.e3().p1.p.glVertex(gl);
+ t.e3().p2.p.glVertex(gl);
gl.glEnd();
}
*/
if (mesh==goal)
- for(Geom.P p : new Geom.P[] { t.p1(), t.p2(), t.p3() }) {
- p.glVertex(gl);
+ for(Geom.V p : new Geom.V[] { t.p1(), t.p2(), t.p3() }) {
+ p.p.glVertex(gl);
//p.plus(p.norm().times(p.score()*10)).glVertex(gl);
- p.partner().glVertex(gl);
+ p.partner().p.glVertex(gl);
//tile.nearest(p).centroid().glVertex(gl);
}
glcanvas.repaint();
//tile.ts.get(Math.abs(random.nextInt()) % tile.ts.size()).e1().p1
for(Geom.T t : tile)
- for(Geom.P p : new Geom.P[] { t.p1(), t.p2(), t.p3() }) {
+ for(Geom.V p : new Geom.V[] { t.p1(), t.p2(), t.p3() }) {
rand(10,p);
}
goal.rescore();