我有以下代码:

largestDeviation = max(max(max(angleBetweenVectors(robustNormal, normalAtA),
                               angleBetweenVectors(robustNormal, normalAtB)),
                           angleBetweenVectors(robustNormal, normalAtC)),
                       angleBetweenVectors(robustNormal, normalAtD)),
                       angleBetweenVectors(robustNormal, normalAtE);


方法:angleBetweenVectors返回一个float

我看不到这段代码在做什么,以及为什么它实际上在构建,括号未正确匹配,恐怕它会导致错误。如何获得对angleBetweenVectors的所有调用的最大值?

最佳答案

添加一些说明,您将获得:

largestDeviation =
max(
   max(
      max(
         angleBetweenVectors(robustNormal, normalAtA),
         angleBetweenVectors(robustNormal, normalAtB)
      ),
      angleBetweenVectors(robustNormal, normalAtC)
   ),
   angleBetweenVectors(robustNormal, normalAtD)
),
angleBetweenVectors(robustNormal, normalAtE);


即当您缺少angleBetweenVectors(robustNormal, normalAtE);时,它将返回max的值

10-08 03:48