Exemplo n.º 1
0
 public int taxi_distance(
     c_vector other)
 {
     return(Math.Abs(x - other.x)
            + Math.Abs(y - other.y)
            + Math.Abs(z - other.z));
 }
Exemplo n.º 2
0
 public c_vector add(c_vector other)
 {
     return(new c_vector(
                x + other.x,
                y + other.y,
                z + other.z));
 }
Exemplo n.º 3
0
        public static c_matrix scale(c_vector s)
        {
            c_matrix result = identity();

            result.values[0, 0] *= s.x;
            result.values[1, 1] *= s.y;
            result.values[2, 2] *= s.z;

            return(result);
        }
Exemplo n.º 4
0
        public static c_matrix translate(c_vector t)
        {
            c_matrix result = identity();

            result.values[0, 3] += t.x;
            result.values[1, 3] += t.y;
            result.values[2, 3] += t.z;

            return(result);
        }
Exemplo n.º 5
0
        public c_vector multiply(c_vector vector)
        {
            // applies the current operation to the inputted vector.

            c_vector result = new c_vector();

            result.x = vector.x * this.values[0, 0]
                       + vector.y * this.values[0, 1]
                       + vector.z * this.values[0, 2]
                       + this.values[0, 3];

            result.y = vector.x * this.values[1, 0]
                       + vector.y * this.values[1, 1]
                       + vector.z * this.values[1, 2]
                       + this.values[1, 3];

            result.z = vector.x * this.values[2, 0]
                       + vector.y * this.values[2, 1]
                       + vector.z * this.values[2, 2]
                       + this.values[2, 3];

            return(result);
        }
Exemplo n.º 6
0
 public bool equal_to(c_vector other)
 {
     return(x == other.x && y == other.y && z == other.z);
 }
Exemplo n.º 7
0
 public c_vector(c_vector other)
 {
     x = other.x;
     y = other.y;
     z = other.z;
 }