문제

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;
}

I guess atan2 can only be used with floats and doubles. but I am trying to do it with an iterator. How would I go about doing the above?

도움이 되었습니까?

해결책

atan2 takes two arguments:

angle = std::atan2(i->y, i->x) * 180 / PI;

should work fine. The correct overload (depending on what CGFloat typedefs to) will be chosen.

Note that i->x and i->y (which are strictly equivalent to (*i).x and (*i).y) are numbers (of type CGFloat), not iterators.

다른 팁

This should work atan2(i->y, i->x) * 180 / PI

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top