vector<CGPoint>::iterator i;
vector<CGPoint>* bp = bicyclePad.bikePathPoints;
for(i = bp->begin(); i != bp->end()-3; i++){
angle = atan2((*i).y/(*i).x) * 180/ PI;
}
我猜 atan2 只能与 float 和 double 一起使用。但我正在尝试使用迭代器来完成它。我将如何去做上述事情?
最佳答案
atan2
接受两个参数:
angle = std::atan2(i->y, i->x) * 180 / PI;
应该可以正常工作。将选择正确的重载(取决于 CGFloat
类型定义)。
请注意 i->x
和 i->y
(它们严格等同于 (*i).x
和 (*i).y
) 是数字(CGFloat
类型),不是迭代器。
关于c++ - atan2 与 CGPoint 迭代器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8761120/