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只能与浮点数和双精度数一起使用。但是我正在尝试用迭代器来做这件事。我该如何去做上面的事情呢?
发布于 2012-01-07 00:35:41
atan2有两个参数:
angle = std::atan2(i->y, i->x) * 180 / PI;应该工作得很好。将选择正确的重载(取决于CGFloat类型定义的类型)。
请注意,i->x和i->y (严格等同于(*i).x和(*i).y)是数字(类型为CGFloat),而不是迭代器。
发布于 2012-01-07 00:36:35
这应该可以工作,atan2(i->y, i->x) * 180 / PI
https://stackoverflow.com/questions/8761120
复制相似问题