indexing description: "[ This class represents a 3d vector. ]" date: "$Date$" revision: "$Revision$" expanded class EM_3D_VECT inherit DOUBLE_MATH export {NONE} all end feature -- Commands set (a_x: DOUBLE; a_y: DOUBLE; a_z: DOUBLE) is -- Set the values do x := a_x y := a_y z := a_z ensure x_set: x = a_x y_set: y = a_y z_set: z = a_z end inc_x (an_double: DOUBLE) is -- Increment x with an_double do x := x + an_double ensure x_incremented: x = old (x) + an_double end inc_y (an_double: DOUBLE) is -- Increment y with an_double do y := y + an_double ensure y_incremented: y = old (y) + an_double end inc_z (an_double: DOUBLE) is -- Increment z with an_double do z := z + an_double ensure z_incremented: z = old (z) + an_double end infix "+" (other: like Current): like Current is -- Add another vector do Result.set (x + other.x, y + other.y, z + other.z) ensure x_added: Result.x = x + other.x y_added: Result.y = y + other.y z_added: Result.z = z + other.z commutative: Result = other + Current end infix "-" (other: like Current): like Current is -- Substract another vector do Result.set (x - other.x, y - other.y, z - other.z) ensure x_substracted: Result.x = x - other.x y_substracted: Result.y = y - other.y z_substracted: Result.z = z - other.z end infix "*" (other: DOUBLE): like Current is -- Multiply with a scalar do Result.set (x * other, y * other, z * other) ensure x_mult: Result.x = x * other y_mult: Result.y = y * other z_mult: Result.z = z * other end length: DOUBLE is -- Return the length do Result := sqrt (x * x + y * y + z * z) ensure result_positive: Result >= 0 end feature -- Status x: DOUBLE -- vector in x direction y: DOUBLE -- vector in y direction z: DOUBLE -- vector in z direction end