Use analytic method if there are only two beams. Otherwise use constrained optimization to find the common beam.
commonbeam()