简体   繁体   English

在坐标系中从 180 度旋转到 -180 度

[英]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.当它应该停止旋转时,我必须创建一个 while 循环条件。 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.编辑:该对象是一架无人机,它向我发送有关其当前沿 z 轴旋转的数据。 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.如果方向是顺时针方向,您将在顺时针方向上分配 0、90、180、270 度的角度。 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.您的 while 循环将用于angle < given angle ,因为根据旋转方向为变量分配值,因此您不必担心角度的 +/- 值。

This is probably a really basic answer and not what you were hoping for, but I hope it helped a little!这可能是一个非常基本的答案,而不是您所希望的,但我希望它会有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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