欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

CommonVectorOperators(常見的向量操作)-創(chuàng)新互聯(lián)

周一到周五,每天一篇,北京時(shí)間早上7點(diǎn)準(zhǔn)時(shí)更新~

成都創(chuàng)新互聯(lián)主營永豐網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都App定制開發(fā),永豐h5重慶小程序開發(fā)公司搭建,永豐網(wǎng)站營銷推廣歡迎永豐等地區(qū)企業(yè)咨詢

Vectors behave as you would expect for operations such as addition, subtraction, unary negation, and so on(向量們經(jīng)常需要進(jìn)行加減乘除這樣的操作). These operators perform a per-component calculation and result in a vector of the same size as their inputs(這些操作得到的結(jié)果依然是一個(gè)同樣維度的向量). The vmath vector classes override the addition, subtraction, and unary negation operators, along with several others, to provide such functionality. This allows you to use code such as(我寫的這個(gè)vmath是個(gè)好青年啊,它里面封裝了這些操作,你可以像下面這些代碼一樣進(jìn)行向量的數(shù)學(xué)運(yùn)算,別忘了關(guān)注我的推特兒哦)

vmath::vec3 a(1.0f, 2.0f, 3.0f);
vmath::vec3 b(4.0f, 5.0f, 6.0f);
vmath::vec3 c;
c = a + b;
c = a - b;
c += b;
c = -c;

However, there are many more operations on vectors that are explained from a mathematical perspective in the following subsections(然而,數(shù)學(xué)意義上,接下來的這部分內(nèi)容將會(huì)講述更多的向量操作). They also have implementations in the vmath library, which will be outlined here(同樣我寫的vmath庫已經(jīng)把下面寫的這些全部都實(shí)現(xiàn)了)

Dot Product(點(diǎn)積)

Vectors can be added, subtracted, and scaled by simply adding, subtracting, or scaling their individual xyz components(向量可以分別對(duì)xyz分量進(jìn)行加減乘數(shù)或者縮放). An interesting and useful operation that can be applied only to two vectors, however, is called the dot product, which is also sometimes known as the inner product(這其中一個(gè)非常有用的只能發(fā)生在向量之間的操作叫點(diǎn)積,人們也管它叫內(nèi)積). The dot product between two (three-component) vectors returns a scalar (just one value) that is the cosine of the angle between the two vectors scaled by the product of their lengths(倆向量的點(diǎn)積得到的是一個(gè)標(biāo)量,這個(gè)標(biāo)量又等于這倆向量的長度相乘后再乘以倆向量的夾角的余弦值). If the two vectors are of unit length, the value returned falls between ?1.0 and 1.0 and is equal to the cosine of the angle between them(如果這倆向量是單位向量,那么點(diǎn)積就等于這倆向量夾角的余弦值了). Of course, to get the actual angle between the vectors, you’d need to take the inverse cosine (or arccosine) of this value(當(dāng)然,為了獲得那個(gè)角度的大小,你需要通過余弦值求arc余弦值). The dot product is used extensively during lighting calculations and is taken between a surface normal vector and a vector pointing toward a light source in diffuse lighting calculations(點(diǎn)積在光照計(jì)算的時(shí)候經(jīng)常會(huì)用到,在漫反射中參與運(yùn)算的向量是法線和一個(gè)指向光源的向量). We will delve deeper into this type of shader code in the “Lighting Models” section in Chapter 13(我們將會(huì)在Ligting Models這個(gè)章節(jié)里來深入了解一下這個(gè)shader的玩法). Figure 4.2 shows two vectors, V1 and V2, and how the angle between them is represented by θ(圖4.2展示了兩個(gè)向量v1和v2,以及他們之間的夾角θ)

Common Vector Operators(常見的向量操作)

Mathematically, the dot product of two vectors V1 and V2 is calculated as(數(shù)學(xué)上,點(diǎn)積的計(jì)算公式如下)

V1 × V2 = V1.x × V2.x + V1.y × V2.y + V1.z × V2.z

The vmath library has some useful functions that use the dot product operation(vmath庫有很多使用了點(diǎn)積的函數(shù)). For starters, you can actually get the dot product itself between two vectors with the function vmath::dot, or with the dot member function of the vector classes(對(duì)于新司機(jī)來說,你可以使用vmath::dot或者是向量的成員函數(shù)來計(jì)算點(diǎn)積)

vmath::vec3 a(...);
vmath::vec3 b(...);
float c = a.dot(b);
float d = dot(a, b);

As we mentioned, the dot product between a pair of unit vectors is a value (between?1.0 and +1.0) that represents the cosine of the angle between them. (就如同我們提到的,兩個(gè)單位向量的點(diǎn)積是這倆向量夾角的余弦值) A slightly higher level function, vmath::angle, actually returns this angle in radians(另一個(gè)更高端的接口vmath::angle計(jì)算的則是兩個(gè)向量之間夾角的大小,單位是弧度)

float angle(const vmath::vec3& u, const vmath::vec3& v);
Cross Product(叉積)

Another useful mathematical operation between two vectors is the cross product, which is also sometimes known as the vector product(另一個(gè)比較有用的操作是叉積). The cross product between two vectors is a third vector that is perpendicular to the plane in which the first two vectors lie(倆向量叉積會(huì)產(chǎn)生一個(gè)垂直于這倆向量所在平面的向量). The cross product of two vectors V1 and V2 is defined as(兩個(gè)向量叉積的定義如下:)

V1 × V2 = ||V1|| ||V2|| sin(θ)n

where n is the unit vector that is perpendicular to both V1 and V2(其中n是垂直于v1和v2的單位向量). This means that if you normalize the result of a cross product, you get the normal to the plane(意思就是說如果你單位化這個(gè)叉積的結(jié)果向量,你就會(huì)得到垂直于一個(gè)平面的法線). If V1 and V2 are both unit length, and are known to be perpendicular to each other, then you don’t even need to normalize the result, as it will also be unit length(如果v1和v2都是單位向量且互相垂直,那么你不需要進(jìn)行單位化了,因?yàn)槟愕玫降慕Y(jié)果就是一個(gè)單位向量). Figure 4.3 shows two vectors, V1 and V2, and their cross product V3(圖4.3展示了v1和v2以及他們的叉積v3)
Common Vector Operators(常見的向量操作)

The cross product of two three-dimensional vectors V1 and V2 can be calculated as(三維向量v1、v2的叉積可以使用如下公式)
Common Vector Operators(常見的向量操作)

Again, the vmath library has functions that take the cross product of two vectors and return the resulting vector: one member function of the three-component vector classes and one global function.(同樣滴,vmath庫有這樣的一個(gè)計(jì)算向量叉積的全局函數(shù)和向量的成員函數(shù),使用方式如下)

vec3 a(...);
vec3 b(...);
vec3 c = a.cross(b);
vec3 d = cross(a, b);

Unlike in the dot product, the order of the vectors in the cross product is important(與點(diǎn)積相比,誰叉了誰這個(gè)順序是不能隨意變動(dòng)的). In Figure 4.3, V3 is the result of V2 cross V1(圖4.3顯示的都是v2叉了v1的結(jié)果v3). If you were to reverse the order of V1 and V2, the resulting vector V3 would point in the opposite direction(如果你用v1去叉v2,那么v3的方向則會(huì)反過來). Applications of the cross product are numerous, from finding surface normals of triangles to constructing transformation matrices(使用叉積的情況還是很多的,從計(jì)算法線到構(gòu)建坐標(biāo)系)

Length of a Vector(向量的長度)

As we have already discussed, vectors have a direction and a magnitude(我們已經(jīng)提到過,向量有方向和長度). The magnitude of a vector is also known as its length. The magnitude of a three-dimensional vector can be found by using the following equation(計(jì)算向量長度的公式如下):
Common Vector Operators(常見的向量操作)

This can be generalized as the square root of the sum of the squares of the components of the vector(這個(gè)就是對(duì)向量各個(gè)部分求平方,然后加起來之后,開平方). In only two dimensions, this is simply Pythagoras’s theorem: The square of the hypotenuse is equal to the sum of the squares of the other two sides(當(dāng)向量是二維向量的時(shí)候,就是說,四邊形的斜邊的平方等于其他兩條邊的平方的和). This extends to any number of dimensions, and the vmath library includes functions to calculate this for you.(這個(gè)可以擴(kuò)展到任意維度,我們vmath庫就已經(jīng)包含了這部分內(nèi)容了)

template 
static inline T length(const vecN& v) { ... }

Reflection and Refraction(反射和折射)

Common operations in computer graphics are calculating reflection and refraction vectors(另外還有一部分的常用的操作就是反射和折射向量了). Given an incoming vector Rin and a normal to a surface N, we wish to know the direction in which Rin will be reflected (Rreflect), and given a particular index of refraction η, the direction in which Rin will be refracted(給出一個(gè)入射光線和物體表面的法線,我們就可以求出反射光線,在進(jìn)一步,給出表面折射率的時(shí)候,俺們還能求出折射光線). We show this in Figure 4.4,with the refracted vectors for various values of η shown as Rrefract,η1 through(圖4.4展示了兩個(gè)不同折射率的時(shí)候,折射光線的情況)
Common Vector Operators(常見的向量操作)

Although Figure 4.4 shows the system in only two dimensions, we are interested in computing this in three dimensions (this is a 3D graphics book, after all). The math for calculating Rreflect is(圖4.4展示的是一個(gè)二維的,我們實(shí)際上對(duì)三維的更感興趣,三維的反射計(jì)算方式如下:)
Common Vector Operators(常見的向量操作)

The math for calculating Rrefract for a given value of η is(三維向量的折射計(jì)算公式如下:)
Common Vector Operators(常見的向量操作)

To get the desired result, both R and N must be unit-length vectors (i.e., they should be normalized before use)(為鳥得到期望的結(jié)果,R和N必須是單位向量). The two vmath functions, reflect() and refract(), implement these equations(vmath庫中的reflect和refract函數(shù)實(shí)現(xiàn)了剛才的這些公式)

本日的翻譯就到這里,明天見,拜拜~~

第一時(shí)間獲取最新橋段,請(qǐng)關(guān)注東漢書院以及圖形之心公眾號(hào)

東漢書院,等你來玩哦

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)站名稱:CommonVectorOperators(常見的向量操作)-創(chuàng)新互聯(lián)
文章路徑:http://aaarwkj.com/article26/hoojg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、電子商務(wù)、微信公眾號(hào)、域名注冊(cè)、企業(yè)網(wǎng)站制作面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計(jì)公司
92国产精品午夜福利| 亚洲欧洲中文字幕一区二区| 日本中文字幕激情在线| 在线观看免费完整观看一区二区 | 国产精品亚洲精品日韩在线| 国产精品视频黄色一区| 人妻艳情一区二区三区| 麻豆精品新av中文字幕| 久久97精品人人做人人爽| 欧亚日韩精品一区二区在线| 91一区二区三区在线| 欧美一级纯黄电影视频| 少妇被按摩高潮在线观看| 久久国产精品av在线观看| 男女午夜激情四射视频| 日韩高清不卡免费视频| 最新日韩欧美不卡一二三区| 91出品国产福利在线| 国产美女极度色诱视频| 欧美美女福利午夜视频| 国产一区二区三区不卡av| 亚洲中文字幕少妇熟女美妇| 又黄又爽又刺激的性视频| 在线播放国产91精品| 天堂av在线一区二区三区| 亚洲黄色av乱码在线观看| 日韩欧美亚洲综合久久精品| 亚洲伦理一区二区三区中文| 超碰97精品在线观看| 亚洲品质自拍在线观看| 精品国产av一区蜜臀av| 国产欧美日韩国产欧美日| 国产精品国产不卡在线| 久久精品免费激情视频| 蜜臀av中文字幕亚洲| 午夜男女激情在线观看| 中文字幕日韩av综合在线| 欧美日韩一区二区三区福利| 国产天美剧情av一区二区| 狠狠久久五月综合色和啪| 欧美黄片在线免费观看|