为什么OpenGL使用度数而不是弧度? [英] Why does OpenGL use degrees instead of radians?

查看:108
本文介绍了为什么OpenGL使用度数而不是弧度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OpenGL设计人员从不惧怕数学,除了最简单的OpenGL应用程序之外,线性代数的知识对于所有其他应用程序都是必不可少的.我认为可以肯定地认为OpenGL程序员熟悉弧度的角度.

The OpenGL designers were never afraid of mathematics, and knowledge of linear algebra is essential for all but the simplest OpenGL applications. I think it can safely be assumed that OpenGL programmers are familiar with angles in radians.

在数学上,弧度在各个方面都比度更优雅.它们还具有实际优势:

Mathematically, radians are more elegant than degrees in every respect. They also have practical advantages:

  • C标准库使用弧度.
  • 几乎所有其他库都使用弧度.
  • 弧度在某些计算中更为方便,例如圆弧的长度.

那么,为什么OpenGL设计者决定决定指定像glRotatefgluPerspective这样的函数来使用度数?

Why, then, did the OpenGL designers decide to specify functions like glRotatef and gluPerspective to use degrees?

(我知道这没有实际意义,并且也不会改变.我只是很好奇,我无法在OpenGL.org上找到答案.)

(I know it's of no practical importance, and it's not going to change anyway. I'm just curious, and I couldn't find the answer on OpenGL.org.)

推荐答案

因为普通人更习惯于计算学位-OpenGL使用起来很简单.请注意,所有按度数操作的功能都是高级"功能.

Because normal people are more used to calculating degrees -- OpenGL is meant to be used simple. Note that all the functions that operate on degrees are "high level" functions.

对于OpenGL本身,无论是接收弧度还是度数都没有什么不同-它们在内部都将转换为变换矩阵,因此使用一种或另一种没有计算上的好处.

For OpenGL itself, it's no difference whether it receives radians or degrees -- they are internally converted to transformation matrices anyway, so there's no computational gain of using one or the other.

那么,如果您可以允许他们使用学位,那为什么还要使人们变得复杂呢?凡是在OpenGL中进行认真编码的人,无论如何都会提供根据四元数计算的矩阵.

So why complicate stuff for people if you can allow them using degrees? Anyone coding seriously in OpenGL will provide their own matrices computated from quaternions anyway.

本着同样的精神,我们会问为什么无论如何都具有glRotatefgluPerspective,因为矩阵在各个方面都更加优雅,并且允许更高级别的控制.

In the same spirit we could ask, why have glRotatef and gluPerspective anyway, since matrices are more elegant in every respect, and allow a higher grade of control.

逐点:

  • 优雅-矩阵在各个方面都更加优雅
  • C库-C库由于计算原因而使用它们,采用角度的GL函数并不意味着要用于计算繁重的任务(直接使用矩阵),并且该实现可能仍然具有用于度数的查找表.
  • 任何其他库-出于与Clib相同的原因而沿用C库-同样,这是不正确的-许多C ++库都允许选择,有些使用后者
  • 计算便利性-没关系-内部表示是矩阵,如果要提高效率,很可能使用查找表进行计算-角度上没有直接操作,所以表示没关系

还要注意:所有使用度数的函数在当前标准(3.2)中已弃用. glRotatef函数,用于获取度数,或者实际上是一个角度. glu 是一个实用程序库,不适合用于繁重的部署,因此它针对可读性量身定制,并且gluPerspective(... 60.0f..)在提供FOV方面比gluPerspective( ... M_PI / 3.0f ... )更具可读性和标准性".

Also note: all of the functions using degrees are in the current standard (3.2) deprecated. glRotatef is the only function taking degrees, or as a matter of fact, an angle at all. glu is a utility library not meant for heavy-duty deployment, hence it's tailored towards readability, and gluPerspective(... 60.0f..) is much more readable and "standard" in terms of supplying FOV than gluPerspective( ... M_PI / 3.0f ... ) would be.

最后的笔记:

这篇关于为什么OpenGL使用度数而不是弧度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆