Port ObstDistAndQuad to Scala