def match(planes)
      raise ArgumentError, "Invalid argument 'planes'. Expected Array, got #{planes.class}." unless planes.is_a?(Array)
      raise ArgumentError, "Invalid argument 'planes'. Expected Array containing only Planes, got #{planes.collect{|p| p.class}.uniq}." unless planes.collect{|p| p.class}.uniq == [Plane]
      # I don't really have a feeling for what a reasonable threshold should be here. Setting it at 0.01.
      # (So far, matched planes have been observed having a deviation in the order of 10e-5 to 10e-7,
      # while some obviously different planes have had values in the range of 8-21)
      deviation_threshold = 0.01
      # Since the 'd' parameter is just a constant selected by us when determining plane equations,
      # the comparison is carried out against the a, b & c parameters.
      # Register deviation for each parameter for each plane:
      a_deviations = NArray.float(planes.length)
      b_deviations = NArray.float(planes.length)
      c_deviations = NArray.float(planes.length)
      planes.each_index do |i|
        # Calculate absolute deviation for each of the three parameters:
        a_deviations[i] = (planes[i].a - @a).abs
        b_deviations[i] = (planes[i].b - @b).abs
        c_deviations[i] = (planes[i].c - @c).abs
      end
      # Compare the deviations of each parameter with the average deviation for that parameter,
      # taking care to adress the case where all deviations for a certain parameter may be 0:
      a_relatives = a_deviations.mean == 0 ? a_deviations : a_deviations / a_deviations.mean
      b_relatives = b_deviations.mean == 0 ? b_deviations : b_deviations / b_deviations.mean
      c_relatives = c_deviations.mean == 0 ? c_deviations : c_deviations / c_deviations.mean
      # Sum the relative deviations for each parameter, and find the index with the lowest summed relative deviation:
      deviations = NArray.float(planes.length)
      planes.each_index do |i|
        deviations[i] = a_relatives[i] + b_relatives[i] + c_relatives[i]
      end
      index = (deviations.eq deviations.min).where[0]
      deviation = a_deviations[index] + b_deviations[index] + c_deviations[index]
      index = nil if deviation > deviation_threshold
      return index
    end
def match(planes)
      raise ArgumentError, "Invalid argument 'planes'. Expected Array, got #{planes.class}." unless planes.is_a?(Array)
      raise ArgumentError, "Invalid argument 'planes'. Expected Array containing only Planes, got #{planes.collect{|p| p.class}.uniq}." unless planes.collect{|p| p.class}.uniq == [Plane]
      # I don't really have a feeling for what a reasonable threshold should be here. Setting it at 0.01.
      # (So far, matched planes have been observed having a deviation in the order of 10e-5 to 10e-7,
      # while some obviously different planes have had values in the range of 8-21)
      deviation_threshold = 0.01
      # Since the 'd' parameter is just a constant selected by us when determining plane equations,
      # the comparison is carried out against the a, b & c parameters.
      # Register deviation for each parameter for each plane:
      a_deviations = NArray.float(planes.length)
      b_deviations = NArray.float(planes.length)
      c_deviations = NArray.float(planes.length)
      planes.each_index do |i|
        # Calculate absolute deviation for each of the three parameters:
        a_deviations[i] = (planes[i].a - @a).abs
        b_deviations[i] = (planes[i].b - @b).abs
        c_deviations[i] = (planes[i].c - @c).abs
      end
      # Compare the deviations of each parameter with the average deviation for that parameter,
      # taking care to adress the case where all deviations for a certain parameter may be 0:
      a_relatives = a_deviations.mean == 0 ? a_deviations : a_deviations / a_deviations.mean
      b_relatives = b_deviations.mean == 0 ? b_deviations : b_deviations / b_deviations.mean
      c_relatives = c_deviations.mean == 0 ? c_deviations : c_deviations / c_deviations.mean
      # Sum the relative deviations for each parameter, and find the index with the lowest summed relative deviation:
      deviations = NArray.float(planes.length)
      planes.each_index do |i|
        deviations[i] = a_relatives[i] + b_relatives[i] + c_relatives[i]
      end
      index = (deviations.eq deviations.min).where[0]
      deviation = a_deviations[index] + b_deviations[index] + c_deviations[index]
      index = nil if deviation > deviation_threshold
      return index
    end
Computes a hash code for this object.

 @note Two objects with the same attributes will have the same hash code.

 @return [Fixnum] the object's hash code

 Compares this Plane instance with an array of planes in order to find the
 index of the plane who's plane equation is closest to the plane equation
 of self.

 @param [Array<Plane>] planes an array of planes to match against
 @return [Fixnumm, NilClass] the index of the matching plane in the specified array (or nil if no planes matched)