<i id='I73Xl'><tr id='I73Xl'><dt id='I73Xl'><q id='I73Xl'><span id='I73Xl'><b id='I73Xl'><form id='I73Xl'><ins id='I73Xl'></ins><ul id='I73Xl'></ul><sub id='I73Xl'></sub></form><legend id='I73Xl'></legend><bdo id='I73Xl'><pre id='I73Xl'><center id='I73Xl'></center></pre></bdo></b><th id='I73Xl'></th></span></q></dt></tr></i><div id='I73Xl'><tfoot id='I73Xl'></tfoot><dl id='I73Xl'><fieldset id='I73Xl'></fieldset></dl></div>
    <bdo id='I73Xl'></bdo><ul id='I73Xl'></ul>
<tfoot id='I73Xl'></tfoot>

<small id='I73Xl'></small><noframes id='I73Xl'>

<legend id='I73Xl'><style id='I73Xl'><dir id='I73Xl'><q id='I73Xl'></q></dir></style></legend>

      1. OpenGL围绕一条线旋转对象

        时间:2023-09-17
        <tfoot id='KSoDA'></tfoot>

          <small id='KSoDA'></small><noframes id='KSoDA'>

                <bdo id='KSoDA'></bdo><ul id='KSoDA'></ul>

                  <legend id='KSoDA'><style id='KSoDA'><dir id='KSoDA'><q id='KSoDA'></q></dir></style></legend>

                  <i id='KSoDA'><tr id='KSoDA'><dt id='KSoDA'><q id='KSoDA'><span id='KSoDA'><b id='KSoDA'><form id='KSoDA'><ins id='KSoDA'></ins><ul id='KSoDA'></ul><sub id='KSoDA'></sub></form><legend id='KSoDA'></legend><bdo id='KSoDA'><pre id='KSoDA'><center id='KSoDA'></center></pre></bdo></b><th id='KSoDA'></th></span></q></dt></tr></i><div id='KSoDA'><tfoot id='KSoDA'></tfoot><dl id='KSoDA'><fieldset id='KSoDA'></fieldset></dl></div>
                    <tbody id='KSoDA'></tbody>
                  本文介绍了OpenGL围绕一条线旋转对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 OpenGL 和 C++ 进行编程.我知道 1 条线上的 2 个点(一条对角线)并希望围绕该对角线旋转一个对象.我该怎么做呢?我知道如何使用 glrotatef 围绕 x、y 或 z 轴旋转它,但我不确定这一点.

                  I am programming in OpenGL and C++. I know 2 points on 1 line (a diagonal line) and wish to rotate an object around that diagonal line. How can I go about doing this? I know how to use glrotatef to rotate it around the x, y or z axis but am not sure about this.

                  推荐答案

                  glRotate 的 x、y 和 z 参数可以指定任意轴,而不仅仅是 x、y 和 z 轴.要找到穿过您的线的轴,只需减去线的端点即可获得轴向量:如果两个点是 (x1, y1, z1)(x2,y2, z2),你需要的轴是(x2-x1, y2-y1, z2-z1).

                  The x, y and z parameters to glRotate can specify any arbitrary axis, not just the x, y and z axes. To find an axis passing through your line, just subtract the end-points of the line to get an axis vector: if the two points are (x1, y1, z1) and (x2, y2, z2), the axis you need is (x2-x1, y2-y1, z2-z1).

                  正如@chris_l 指出的那样,这仅在线条通过原点时才有效.如果不是,首先应用 (-x1, -y1, -z1) 的平移,使线通过原点,然后应用上述旋转,并通过 (x1, y1, z1).

                  As @chris_l pointed out, this works only if the line passes through the origin. If not, first apply a translation of (-x1, -y1, -z1) so that the line passes through the origin, then apply the above rotation, and translate it back by (x1, y1, z1).

                  这篇关于OpenGL围绕一条线旋转对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:3D 应用程序中的 OpenGL 2D hud 下一篇:与基本逻辑代码相比,OpenGL glDrawElements() 调用的

                  相关文章

                  最新文章

                • <legend id='xeUvz'><style id='xeUvz'><dir id='xeUvz'><q id='xeUvz'></q></dir></style></legend>
                • <i id='xeUvz'><tr id='xeUvz'><dt id='xeUvz'><q id='xeUvz'><span id='xeUvz'><b id='xeUvz'><form id='xeUvz'><ins id='xeUvz'></ins><ul id='xeUvz'></ul><sub id='xeUvz'></sub></form><legend id='xeUvz'></legend><bdo id='xeUvz'><pre id='xeUvz'><center id='xeUvz'></center></pre></bdo></b><th id='xeUvz'></th></span></q></dt></tr></i><div id='xeUvz'><tfoot id='xeUvz'></tfoot><dl id='xeUvz'><fieldset id='xeUvz'></fieldset></dl></div>
                • <tfoot id='xeUvz'></tfoot>

                      <small id='xeUvz'></small><noframes id='xeUvz'>

                      • <bdo id='xeUvz'></bdo><ul id='xeUvz'></ul>