gpt4 book ai didi

c++ - max 函数的奇怪行为

转载 作者:太空宇宙 更新时间:2023-11-04 14:48:53 27 4
gpt4 key购买 nike

我有这个代码:

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

关于c++ - max 函数的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23045259/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com