Chapter 4. Math for 3D Graphics(3D图形中的数学)
admin
2023-02-11 04:40:06
0

周一到周五,每天一篇,北京时间早上7点准时更新~

What You’ll Learn in This Chapter(本章你将会学到啥)

What a vector is, and why you should care about them(什么是向量以及为什么你需要注意他们)
What a matrix is, and why you should care more about them(什么是矩阵以及为什么你需要更注意它们)
How we use matrices and vectors to move geometry around(我们如何使用矩阵和向量来移动几何物体)
What the OpenGL conventions and coordinate spaces are(OpenGL中的转换以及坐标空间是啥)
So far, you have learned to draw points, lines, and triangles and have written simple shaders that pass your hard-coded vertex data through unmodified(现在,你已经学过了如何绘制点、线以及三角形,并且我们写了一些简单的shader,它们不对数据进行修改,仅仅是起到了在图形管线中传递数据的作用). We haven’t really been rendering in 3D—which is odd for a book on 3D graphics!(我们还没有真正的渲染3D的东西,这对于一本3D图形的书来说不是很奇怪吗) Well, to turn a collection of shapes into a coherent scene, you must arrange them in relation to one another and to the viewer(然而,要有条理的去在3D场景中组织物体,你必须管理他们之间的相对关系以及和摄像机的关系). In this chapter, you start moving shapes and objects around in your coordinate system(在本小节,你将开始在你的坐标系统中移动物体). The ability to place and orient your objects in a scene is a crucial tool for any 3D graphics programmer(对于3D程序员来说,在场景中去放置和旋转物体的能力是非常关键的). As you will see, it is actually convenient to describe your objects’ dimensions around the origin and then transform the objects into the desired positions(你将会看到,去定义物体的维度以及控制物体的位置还是比较容易的)

Is This the Dreaded Math Chapter?(这是一个狗带的数学章节吗)

In most books on 3D graphics programming, yes, this would be the dreaded math chapter(在大多数3D图形书籍里,确实,这就是一章狗带的数学内容). However, you can relax; we take a more moderate approach to these principles than some texts(不过,你可以放轻松,我们将使用一些更舒适的手段来讲解这些原理而不是紧靠文字描述)

One of the fundamental mathematical operations that will be performed by your shaders is the coordinate transform, which boils down to multiplying matrices with vectors and with each other(最基本的数学操作中的一个就是你会在shader中用到的坐标系转换,它涉及到矩阵与矩阵以及矩阵与向量的乘法). The keys to object and coordinate transformations are two matrix conventions used by OpenGL programmers(对于OpenGL程序员来说,坐标系转换的关键在于两个矩阵). To familiarize you with these matrices, this chapter strikes a compromise between two extremes in computer graphics philosophy(为了让你熟悉 这些矩阵,本章节将采用计算机图形学中两种极端 思路的这种方案来进行讲解). On the one hand, we could warn you, “Please review a textbook on linear algebra before reading this chapter.”(一方面,我们会警告你说,请在阅读本章之前,先看一看线性代数的 书) On the other hand, we could perpetuate the deceptive reassurance that you can “learn to do 3D graphics without all those complex mathematical formulas.”(另一方面,我们也会不断的告诉你,即便没有那些复杂的数学理论,你也可以学会3D图形学) But we don’t agree with either camp(但是,我们实际上两边都不同意)

In reality, you can get along just fine without understanding the finer mathematics of 3D graphics, just as you can drive your car every day without having to know anything at all about automotive mechanics and the internal combustion engine(实际上,你可以在不必精通3D数学的情况下,很好的处理3D编程问题,就像你不必懂什么汽车生产以及发动机的原理就能开车一样). But you had better know enough about your car to realize that you need an oil change every so often, that you have to fill the tank with gas regularly, and that you must change the tires when they get bald(但是你最好是更多的了解你的车子,这样你就可以知道什么时候该加油了 ,什么时候该打气了). This knowledge makes you a responsible (and safe!) automobile owner(这些知识能让你更好的玩转你的车子). If you want to be a responsible and capable OpenGL programmer, the same standards apply(如果你希望变成一个更强的OpenGL程序员,道理是一样的). You need to understand at least the basics so you know what can be done and which tools best suit the job(你至少需要了解最基本的数学,这样你才能知道你可以做什么以及什么工具是最适合你的项目的). If you are a beginner you will find that, with some practice, matrix math and vectors will gradually make more sense, and you will develop a more intuitive (and powerful) ability to make full use of the concepts we introduce in this chapter(如果你是一个新手,你将会发现,随着不断的练习,你将会得到更多的矩阵以及向量方面的体会,并且你将能更好的去理解我们本章节提到的这些概念)

So even if you don’t already have the ability to multiply two matrices in your head, you need to know what matrices are and how they serve as the means to OpenGL’s 3D magic(所以,即便你不知道如何计算矩阵的乘法,你需要知道什么是矩阵,以及他们在OpenGL中的意义). But before you go dusting off that old linear algebra textbook (doesn’t everyone have one?)(但是在你开始再次翻开你的线性代数课本之前,不要害怕:因为我们的sb7库里面应包含了一个叫vmath的组件,它能很好的帮你解决数学计算方面的问题), have no fear: The sb7 library has a component called vmath that contains a number of useful classes and functions that can be used to represent and manipulate vectors and matrices. They can be used directly with OpenGL and are very similar in syntax and appearance to GLSL—the language you’ll be writing your shaders in(他们可以像你即将在shader中使用矩阵的方式一样使用). So, you don’t have to do all your matrix and vector manipulation yourself, but it’s still a good idea to know what they are and how to apply them(所以你并不需要自己亲手实现所有这些数学计算,但是知道怎么实现这些数学计算以及如何应用他们任然是值得你努力的方向). See—you can eat your cake and have it, too!

本日的翻译就到这里,明天见,拜拜~~

第一时间获取最新桥段,请关注东汉书院以及图形之心公众号

东汉书院,等你来玩哦

相关内容

热门资讯

终于了解“冲关游戏开挂神器?”... 终于了解“冲关游戏开挂神器?”(必胜开挂神器)您好,冲关游戏这个游戏其实有挂的,确实是有挂的,需要了...
今日重大发现“喜扣跑胡子开挂神... 家人们!今天小编来为大家解答喜扣跑胡子透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里买...
美国更需要?外媒关注中国“集装... 【文/观察者网 山猫】近年来,中国军事装备建设新成果不断涌现,特别是2024年底时,两种据信是第六代...
最新引进“万人玩麻将真的有挂吗... 网上科普关于“万人玩麻将有没有挂”话题很是火热,小编也是针对万人玩麻将作*弊开挂的方法以及开挂对应的...
我来教教您“潘潘讲故事到底是不... 我来教教您“潘潘讲故事到底是不是挂?”(详细开挂教程)您好,潘潘讲故事这个游戏其实有挂的,确实是有挂...
平安家办企业家国际峰会收官 东... 近日,由平安家族办公室主办的“全球视野·东方智慧”企业家国际峰会,在北京圆满收官。 近日,由平安家...
最新引进“普通扑克三公提前知道... 家人们!今天小编来为大家解答普通扑克三公提前知道大小透视挂怎么安装这个问题咨询软件客服徽975294...
九丰能源:长征八号甲运载火箭发... 12月26日,有投资者在互动平台向九丰能源(605090.SH)提问,26号海南商发长八甲发射用的附...
重磅消息“一喜棋牌是不是有挂?... 网上科普关于“一喜棋牌有没有挂”话题很是火热,小编也是针对一喜棋牌作*弊开挂的方法以及开挂对应的知识...
今日重磅消息“潘潘讲故事辅助器... 您好:潘潘讲故事这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9784099】很多玩家在这款游...