简体   繁体   English

围绕一个点旋转 object

[英]Rotate a object around a point

how would I rotate an object around an object, such as rotating an object in circles around another object?我将如何围绕 object 旋转 object,例如围绕另一个 ZA8CFDE6331BD59EB66AC96F8911 旋转 object? Preferably using GL.Rotate and as little math as possible!最好使用 GL.Rotate 和尽可能少的数学!

GL.Rotate defines a rotation matrix, that rotates a round 0.0. GL.Rotate定义了一个旋转矩阵,它旋转了一个圆形 0.0。 If you want to rotate around a pivot ( pivotX , pivotY ) you have to:如果您想围绕 pivot ( pivotX , pivotY ) 旋转,您必须:

  1. Translate the object so that the pivot point is moved to (0, 0).平移 object,使 pivot 点移动到 (0, 0)。
  2. Rotate the object.旋转 object。
  3. Move the object so that the pivot point moves in its original position.移动 object,使 pivot 点在其原始 position 中移动。

eg:例如:

GL.Translate(pivotX, pivotY, 0);    // 3. move back
GL.Roatate(angle, 0, 0, 1);         // 2. rotate
GL.Translate(-pivotX, -pivotY, 0);  // 1. move pivot to (0, 0) 

See also How to use Pivot Point in Transformations另请参阅如何在转换中使用 Pivot 点

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

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