A Geometry Problem in Scala