2021/19/sol1.rb
# each group's scanners have coordinates relative to the coordinate system of
# the first scanner in the group
each group's scanners have coordinates relative to the coordinate system of
the first scanner in the group
each group ' s scanners have coordinates relative to the coordinate system of the first scanner in the group
def reconcile(scanner1, scanner2)
  scanner2.orientations.each do |orient|
    translations = []
    orient.coords.each do |u|
      scanner1.coords.each do |v|
        translations << diff(u, v)
      end
    end
    translations.group_by(&:itself).values.each do |a|
      if a.size >= 12
        v = a.first
        p ['translation', v]
        return Scanner.new(orient.coords.map { |c| diff(c, v) })
      end
    end
  end
  nil
end
def reconcile ( scanner1 , scanner2 ) scanner2 . orientations . each do | orient | translations = [ ] orient . coords . each do | u | scanner1 . coords . each do | v | translations << diff ( u , v ) end end translations . group_by ( & :itself ) . values . each do | a | if a . size >= 12 v = a . first p [ 'translation' , v ] return Scanner . new ( orient . coords . map { | c | diff ( c , v ) } ) end end end nil end
each group's scanners have coordinates relative to the coordinate system of
the first scanner in the group
each group ' s scanners have coordinates relative to the coordinate system of the first scanner in the group
scanner1
<not_specific>
scanner2
<not_specific>