简体   繁体   中英

Calculate pi of a radian that can be negative or positive?

I have a variable A which is a radian angle value. I also have a variable B that should always be PI away from A. How can I verify that B is PI off of A with 0.01 accuracy in negative or positive direction (C++)? A's value can be negative.

Peter's answer in the comments suited well to this problem: std::abs(std::abs(a - b) - pi) <= 0.01

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