public Iterator<T> iterator() { return ts.iterator(); }
- public P origin() { return newP(0, 0, 0); }
+ public P origin() { return new P(0, 0, 0); }
public Geom score_against = null;
public double score = 0;
(float)(max_z + min_z)/2);
}
- public P newP(double x, double y, double z) { return newP((float)x, (float)y, (float)z); }
- public P newP(float x, float y, float z) { return new P(x, y, z); }
-
public T newT(V p12, V p23, V p31, Vec norm) {
Vec norm2 = p31.p.minus(p12.p).cross(p23.p.minus(p12.p));
float dot = norm.dot(norm2);
return newT(p12, p23, p31);
}
-
public float volume() {
double total = 0;
for(T t : ts) {
double area = t.area();
- Vec origin_to_centroid = new Vec(newP(0, 0, 0), t.centroid());
+ Vec origin_to_centroid = new Vec(new P(0, 0, 0), t.centroid());
boolean facingAway = t.norm().dot(origin_to_centroid) > 0;
double height = Math.abs(t.norm().dot(origin_to_centroid));
total += ((facingAway ? 1 : -1) * area * height) / 3.0;
}
public V partner() { return watch==null ? this : watch; }
public V watchback() { return watch_count==0 ? partner() :
- newP(watch_x/watch_count, watch_y/watch_count, watch_z/watch_count).register(); }
+ new P(watch_x/watch_count, watch_y/watch_count, watch_z/watch_count).register(); }
public void rescore() {
if (score_against == null) return;
public class P {
float x, y, z;
+ public P(double x, double y, double z) { this((float)x, (float)y, (float)z); }
public P(float x, float y, float z) { this.x = x; this.y = y; this.z = z; }
public float distance(P p) { return distance(p.x, p.y, p.z); }
public float distance(float ox, float oy, float oz) { return (float)Math.sqrt((x-ox)*(x-ox)+(y-oy)*(y-oy)+(z-oz)*(z-oz)); }
public V register() { V v = ps.get(this); return v==null ? new V(this) : v; }
public P times(M m) { return m.times(this); }
public Vec minus(P p) { return new Vec(x-p.x, y-p.y, z-p.z); }
- public P plus(Vec v) { return newP(x+v.x, y+v.y, z+v.z); }
+ public P plus(Vec v) { return new P(x+v.x, y+v.y, z+v.z); }
public boolean equals(Object o) { return o!=null && (o instanceof P) && ((P)o).x==x && ((P)o).y==y && ((P)o).z==z; }
public void glVertex(GL gl) { _glVertex(gl); }
private void _glVertex(GL gl) { gl.glVertex3f(x, y, z); }
this.pair = pair;
sync();
}
- public P midpoint() { return newP((p1.p.x+p2.p.x)/2, (p1.p.y+p2.p.y)/2, (p1.p.z+p2.p.z)/2); }
+ public P midpoint() { return new P((p1.p.x+p2.p.x)/2, (p1.p.y+p2.p.y)/2, (p1.p.z+p2.p.z)/2); }
public boolean has(V v) { return v==p1 || v==p2; }
public float length() { return p1.p.minus(p2.p).mag(); }
public String toString() { return p1+"->"+p2; }
p3().p.glVertex(gl);
}
- public P centroid() { return newP((p1().p.x+p2().p.x+p3().p.x)/3,
+ public P centroid() { return new P((p1().p.x+p2().p.x+p3().p.x)/3,
(p1().p.y+p2().p.y+p3().p.y)/3,
(p1().p.z+p2().p.z+p3().p.z)/3); }
public float diameter() {
d = h = l = 0;
}
public P times(P p) {
- return newP(a*p.x + b*p.y + c*p.z + d,
+ return new P(a*p.x + b*p.y + c*p.z + d,
e*p.x + f*p.y + g*p.z + h,
i*p.x + j*p.y + k*p.z + l);
}
public Main(StlFile stlf) {
for(int i=0; i<stlf.coordArray.length; i+=3) {
- Geom.V p0 = goal.newP(stlf.coordArray[i+0].x * MAG, stlf.coordArray[i+0].y * MAG, stlf.coordArray[i+0].z * MAG).register();
- Geom.V p1 = goal.newP(stlf.coordArray[i+1].x * MAG, stlf.coordArray[i+1].y * MAG, stlf.coordArray[i+1].z * MAG).register();
- Geom.V p2 = goal.newP(stlf.coordArray[i+2].x * MAG, stlf.coordArray[i+2].y * MAG, stlf.coordArray[i+2].z * MAG).register();
+ Geom.V p0 = goal.new P(stlf.coordArray[i+0].x * MAG, stlf.coordArray[i+0].y * MAG, stlf.coordArray[i+0].z * MAG).register();
+ Geom.V p1 = goal.new P(stlf.coordArray[i+1].x * MAG, stlf.coordArray[i+1].y * MAG, stlf.coordArray[i+1].z * MAG).register();
+ Geom.V p2 = goal.new P(stlf.coordArray[i+2].x * MAG, stlf.coordArray[i+2].y * MAG, stlf.coordArray[i+2].z * MAG).register();
Geom.Vec n = goal.new 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);
}
};
- Geom.V ltf = tile.newP(-(width/2), (height/2), (depth/2)).register();
- Geom.V mtf = tile.newP( 0.0, (height/2), (depth/2)).register();
- Geom.V rtf = tile.newP( (width/2), (height/2), (depth/2)).register();
- Geom.V ltn = tile.newP(-(width/2), (height/2), -(depth/2)).register();
- Geom.V mtn = tile.newP( 0.0, (height/2), -(depth/2)).register();
- Geom.V rtn = tile.newP( (width/2), (height/2), -(depth/2)).register();
- Geom.V lbf = tile.newP(-(width/2), -(height/2), (depth/2)).register();
- Geom.V mbf = tile.newP( 0.0, -(height/2), (depth/2)).register();
- Geom.V rbf = tile.newP( (width/2), -(height/2), (depth/2)).register();
- Geom.V lbn = tile.newP(-(width/2), -(height/2), -(depth/2)).register();
- Geom.V mbn = tile.newP( 0.0, -(height/2), -(depth/2)).register();
- Geom.V rbn = tile.newP( (width/2), -(height/2), -(depth/2)).register();
+ Geom.V ltf = tile.new P(-(width/2), (height/2), (depth/2)).register();
+ Geom.V mtf = tile.new P( 0.0, (height/2), (depth/2)).register();
+ Geom.V rtf = tile.new P( (width/2), (height/2), (depth/2)).register();
+ Geom.V ltn = tile.new P(-(width/2), (height/2), -(depth/2)).register();
+ Geom.V mtn = tile.new P( 0.0, (height/2), -(depth/2)).register();
+ Geom.V rtn = tile.new P( (width/2), (height/2), -(depth/2)).register();
+ Geom.V lbf = tile.new P(-(width/2), -(height/2), (depth/2)).register();
+ Geom.V mbf = tile.new P( 0.0, -(height/2), (depth/2)).register();
+ Geom.V rbf = tile.new P( (width/2), -(height/2), (depth/2)).register();
+ Geom.V lbn = tile.new P(-(width/2), -(height/2), -(depth/2)).register();
+ Geom.V mbn = tile.new P( 0.0, -(height/2), -(depth/2)).register();
+ Geom.V rbn = tile.new P( (width/2), -(height/2), -(depth/2)).register();
points = new Geom.V[] {
ltf,
//if (v1.z==0 && v1.y==0) continue;
i++;
if (i != 1 /*&& i!=4*/) continue;
- Geom.V p = tile.newP(0, 0, 0).times(m).register();
+ Geom.V p = tile.new P(0, 0, 0).times(m).register();
Geom.Vec v = tile.new Vec(p.p.x, p.p.y, p.p.z);
v = v.times((float)1.04);
gl.glTranslatef(v.x, v.y, v.z);