简体   繁体   中英

Rotating in coordination system from 180 to -180

I am thinking about the simplest way of rotating an object in coordination system which looks like this:

       0

-90         90

   -180/180

I need to rotate an object until it reaches a given angle. It has to support rotation in both directions. I receive information about the object's current rotation. I have to create a while loop condition when it should stop rotating. It cannot be simple equality statement as the information I receive is not that precise.

EDIT: The object is a drone which sends me data about its current rotation along z-axis. I rotate it by sending a request to rotate in a given direction. Based on information about its current rotation and the angle by which I want him to rotate (plus the direction of rotation), I need to set up a condition when it should stop rotating and send an apropriate requst.

Theoretically, you would need to have another variable that took the direction of rotation (clockwise or anti-clockwise). If the direction was clockwise, you would have angles assigned 0, 90, 180, 270 in clockwise direction. Same for anticlockwise.

Your while loop would be for angle < given angle , since with the variables being assigned values based on the direction of rotation you wouldn't have to worry about +/- values for the angles.

This is probably a really basic answer and not what you were hoping for, but I hope it helped a little!

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