Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 public static Vector unit(Vector a)
 {
     Vector r = a.truediv(a.norm());
     return r;
 }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
0
 //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);
 }
Exemplo n.º 10
0
        //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);
        }