简体   繁体   中英

atan2 with CGPoint Iterator

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.

这应该可以工作atan2(i->y, i->x) * 180 / PI

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM