public Vector sub(Vector other) { return new Vector(this.x.theValue - other.x.theValue, this.y.theValue - other.y.theValue, this.z.theValue - other.z.theValue); }
public Vector iadd(Vector other) { this.x.theValue += other.x.theValue; this.y.theValue += other.y.theValue; this.z.theValue += other.z.theValue; return this; }
public Vector isub(Vector other) { this.x.theValue -= other.x.theValue; this.y.theValue -= other.y.theValue; this.z.theValue -= other.z.theValue; return this; }
public Vector add(Vector other) { return new Vector(this.x.theValue + other.x.theValue, this.y.theValue + other.y.theValue, this.z.theValue + other.z.theValue); }
public Vector div(Vector other) { return new Vector(this.x.theValue / other.x.theValue, this.y.theValue / other.y.theValue, this.z.theValue / other.z.theValue); }
public Triangle(Vertex u, Vertex v, Vertex w, int group) { this.u = u; this.v = v; this.w = w; this.n = KCLWriter.unit(KCLWriter.cross(v.sub(u), w.sub(u))); this.group = group; }
public static Vector unit(Vector a) { Vector r = a.truediv(a.norm()); return r; }
public static float dot(Vertex a, Vector b) { return a.x.theValue * b.x.theValue + a.y.theValue * b.y.theValue + a.z.theValue * b.z.theValue; }
//Vertex, Vector > Vector public static Vector cross(Vertex a, Vector b) { return new Vector(a.y.theValue * b.z.theValue - a.z.theValue * b.y.theValue, a.z.theValue * b.x.theValue - a.x.theValue * b.z.theValue, a.x.theValue * b.y.theValue - a.y.theValue * b.x.theValue); }
//For dealing with type Vector public int add(Vector v) { int min_ix = (int)((v.x.theValue - this.threshold) / this.cell_width); int min_iy = (int)((v.y.theValue - this.threshold) / this.cell_width); int min_iz = (int)((v.z.theValue - this.threshold) / this.cell_width); int max_ix = (int)((v.x.theValue + this.threshold) / this.cell_width); int max_iy = (int)((v.y.theValue + this.threshold) / this.cell_width); int max_iz = (int)((v.z.theValue + this.threshold) / this.cell_width); for (int ix = min_ix; ix < max_ix + 1; ix++) { for (int iy = min_iy; iy < max_iy + 1; iy++) { for (int iz = min_iz; iz < max_iz + 1; iz++) { foreach (int index in this.buckets[(int)this.vertex_hash(ix, iy, iz)]) { if (v.sub(this.vectors[index]).norm_sq() < this.threshold * this.threshold) return index; } } } } this.vectors.Add(v); this.buckets[(int)this.vertex_hash((int)(v.x.theValue / this.cell_width), (int)(v.y.theValue / this.cell_width), (int)(v.z.theValue / this.cell_width))].Add(this.vectors.Count - 1); return (this.vectors.Count - 1); }