版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
Unity的坐標(biāo)系Unity采用左手坐標(biāo)系Vector3Vector3類描述三維矢量和三維空間點(diǎn),是三維運(yùn)算中最基本的數(shù)學(xué)操作.Vector3v=newVector3(1.0f,1.0f,1.0f);print(v);Vector3的靜態(tài)性質(zhì)PropertiesVector3back=Vector3.back;//(0,0,-1)Vector3down=Vector3.down;//(0,-1,0)Vector3forward=Vector3.forward;//(0,0,1)Vector3left=Vector3.left;//(-1,0,0)Vector3one=Vector3.one;//(1,1,1)Vector3right=Vector3.right;//(1,0,0)Vector3up=Vector3.up;//(0,1,0)Vector3zero=Vector3.zero;//(0,0,0)Vector3的一般性質(zhì)Properties獲取矢量v的三個(gè)坐標(biāo)分量:獲取矢量v的長度:獲取矢量v的單位矢量:Vector3的靜態(tài)方法publicstaticfloatAngle(Vector3from,Vector3to);獲取小于180度的夾角。publicstaticfloatSignedAngle(Vector3f,Vector3t,Vector3axis);獲取夾角,該夾角可以大于180度。publicstaticVector3Cross(Vector3lhs,Vector3rhs);publicstaticfloatDot(Vector3lhs,Vector3rhs);Vector3a=newVector3(2,0,0);Vector3b=newVector3(0,2,0);floatx=Vector3.Dot(a,b);Vector3MoveTowards(Vector3current,Vector3target,floatmaxDistanceDelta);voidOrthoNormalize(refVector3normal,refVector3tangent);將矢量normal和tangent歸一,同時(shí)將tangent方向垂直于normal。voidOrthoNormalize(refVector3normal,refVector3tangent,refVector3binormal);
Vector3
Project(Vector3
vector,
Vector3
onNormal);Projects
vector
ontovectoronNormal.Vector3ProjectOnPlane(Vector3vector,Vector3planeNormal);Projectsavectorontoaplanedefinedbyanormalorthogonaltotheplane.planeNormalVector3
Reflect(Vector3
inDirection,
Vector3
inNormal)Reflectsavectorofftheplanedefinedbyanormal.Vector3RotateTowards(Vector3current,Vector3
target,floatmaxRadiansDelta,floatmaxMagnitudeDelta);Rotatesavectorcurrenttowardstarget.staticVector3Scale(Vector3a,Vector3b);publicvoidScale(Vector3scale);Result=(a.x*b.x,a.y*b.y,a.z*b.z);
staticfloatSignedAngle(Vector3from,Vector3to,Vector3axis);Returnsthesignedangleindegreesbetweenfromandto.staticVector3Slerp(Vector3a,Vector3b,floatt);Sphericallyinterpolatesbetweentwovectors.Interpolatesbetweenaandbbyamountt.Vector3v1=newVector3(2.0f,1.0f,0.0f);Vector3v2=newVector3(-2.0f,1.0f,0.0f);for(inti=1;i<10;++i){Vector3v=Vector3.Slerp(v1,v2,0.1f*i);Debug.DrawLine(Vector3.zero,v,Color.yellow);}
staticVector3SlerpUnclamped(Vector3a,Vector3b,floatt);tcanbelessthanzeroorgreaterthanonestaticVector3SmoothDamp(Vector3current,Vector3target,refVector3currentVelocity,floatsmoothTime,floatmaxSpeed=Mathf.Infinity,floatdeltaTime=Time.deltaTime);Operatorsoperator-Subtractsonevectorfromanother.operator!=Returnstrueifvectorsdifferent.operator*Multipliesavectorbyanumber.operator/Dividesavectorbyanumber.operator+Addstwovectors.operator==Returnstrueiftwovectorsareapproximatelyequal.Vector2andVector4ScalingTransformsRotationTransformsHomogeneousCoordinatesA3DpointPisextendedtofourdimensionsbysettingitsfourthcoordinate,whichwecallthewcoordinate,equalto1.(x,y,z,w),w=1,Translationmatrix????Matrix4x4Atransformationmatrixcanperformarbitrarylinear3Dtransformations(i.e.translation,rotation,scale,shearetc.)andperspectivetransformationsusinghomogenouscoordinates.先平移,再旋Matrix4x4matrix=newMatrix4x4(newVector4(1,2,3,4),newVector4(5,6,7,8),newVector4(9,10,11,12),newVector4(13,14,15,16));Matrix4x4me=Matrix4x4.identity;Debug.Log(m0);Matrix4x4m0=Matrix4x4.zero;Debug.Log(m0);Matrix4x4matrix=newMatrix4x4(newVector4(1,2,3,4),newVector4(5,6,7,8),newVector4(9,10,11,12),newVector4(13,14,15,16));Matrix4x4mi=matrix.transpose;Debug.Log(matrix);Debug.Log(mi);Quaternionquat=matrix.rotation;Debug.Log(quat);Matrix4x4mt=matrix.inverse;Debug.Log(mt);PublicmethodsGetColumnGetacolumnofthematrix.GetRowReturnsarowofthematrix.MultiplyPointTransformsapositionbythismatrix(generic).MultiplyPoint3x4Transformsapositionbythismatrix(fast).MultiplyVectorTransformsadirectionbythismatrix.SetColumnSetsacolumnofthematrix.SetRowSetsarowofthematrix.SetTRSSetsthismatrixtoatranslation,rotationandscalingmatrix.ToStringReturnsanicelyformattedstringforthismatrix.TransformPlaneReturnsaplanethatistransformedinspace.ValidTRSChecksifthismatrixisavalidtransformmatrix.StaticMethodsFrustumThisfunctionreturnsaprojectionmatrixwithviewing.LookAtGivenasourcepoint,atargetpoint,andanupvector.OrthoCreatesanorthogonalprojectionmatrix.PerspectiveCreatesaperspectiveprojectionmatrix.RotateCreatesarotationmatrix.ScaleCreatesascalingmatrix.TranslateCreatesatranslationmatrix.TRSCreatesatranslation,rotationandscalingmatrix.StaticmethodsinMatrix4x4//旋轉(zhuǎn)Matrix4x4mr=Matrix4x4.Rotate(newQuaternion(0.1f,0.2f,0.3f,1.0f));//縮放Matrix4x4ms=Matrix4x4.Scale(newVector3(0.1f,0.1f,0.1f));//平移Matrix4x4mt=Matrix4x4.Translate(newVector3(10f,0f,0f));Matrix4x4matrix=Matrix4x4.TRS(newVector3(1,0,0),Quaternion.identity,newVector3(1,1,1));Debug.Log(matrix);AttitudeandheadingNormalsituation,GimbalLockQuaternionsAquaternionisanalternativemathematicalentitythat3Dgraphicsprogrammersusetorepresentrotations.RotationswithQuaternionstheunitquaternionqcorrespondingtoarotationthroughtheangleθabouttheaxisAisgivenbyconvertaquaternionintotheequivalent3×3rotationmatrix:PropertieseulerAngles:Returnsorsetstheeulerangle.normalized:Returnsthisquaternionwithamagnitudeof1.this[int]:Accessthex,y,z,wcomponentsusing[0],[1],[2],[3].w: WcomponentoftheQuaternion.x: XcomponentoftheQuaternion.y: YcomponentoftheQuaternion.z: ZcomponentoftheQuaternion.publicVector3eulerAngles{get;set;}quaternion=newQuaternion(0.0f,0.0f,0.0f,1.0f);cube.transform.rotation=quaternion;Vector3angles=quaternion.eulerAngles;Quaternion的實(shí)例方法Set:Setx,y,zandwcomponentsofanexistingQuaternion.SetFromToRotation:CreatesarotationwhichrotatesfromfromDirectiontotoDirection.SetLookRotation:Createsarotationwiththespecifiedforwardandupwardsdirections.ToAngleAxis:Convertsarotationtoangle-axisrepresentation(anglesindegrees).ToString:ReturnsanicelyformattedstringoftheQuaternion.Quaternionq=Quaternion.identity;q.SetFromToRotation(v1,v2);transform.rotation=q;publicvoidSetLookRotation(Vector3view,Vector3up=Vector3.up);Quaternionquat=newQuaternion();quat.SetLookRotation(Vector3.down,Vector3.left);transform.rotation=quat;Angle:Returnstheangleindegreesbetweentworotationsaandb.AngleAxis:Createsarotationwhichrotatesangledegreesaroundaxis.Dot: Thedotproductbetweentworotations.Euler:Returnsarotationthatrotateszdegreesaroundthezaxis,xdegreesaroundthexaxis,andydegreesaroundtheyaxi
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- GB/T 32589-2025軌道交通導(dǎo)電軌受流器
- 海外培訓(xùn)主播
- 軋光(軋花)機(jī)擋車工崗前成果轉(zhuǎn)化考核試卷含答案
- 海藻飼料肥料制作工安全宣傳模擬考核試卷含答案
- 配氣分析工沖突解決水平考核試卷含答案
- 銀行內(nèi)部審計(jì)檔案歸檔規(guī)范制度
- 酒店員工交接班制度
- 那坡昂屯風(fēng)電場項(xiàng)目送出線路工程項(xiàng)目環(huán)境影響報(bào)告表
- 流行樂唱歌培訓(xùn)
- 如何報(bào)考執(zhí)業(yè)藥師?-2026年政策適配+全流程避坑指南
- 監(jiān)獄消防培訓(xùn) 課件
- 道路建設(shè)工程設(shè)計(jì)合同協(xié)議書范本
- 白塞病患者外陰潰瘍護(hù)理查房
- 西葫蘆的栽培技術(shù)
- 2025年安徽阜陽市人民醫(yī)院校園招聘42人筆試模擬試題參考答案詳解
- 2024~2025學(xué)年江蘇省揚(yáng)州市樹人集團(tuán)九年級(jí)上學(xué)期期末語文試卷
- 2026屆江蘇省南京溧水區(qū)四校聯(lián)考中考一模物理試題含解析
- 2025年黑龍江省公務(wù)員《申論(行政執(zhí)法)》試題(網(wǎng)友回憶版)含答案
- 公司大型綠植自營活動(dòng)方案
- 智能客戶服務(wù)實(shí)務(wù)(第三版)課件 項(xiàng)目三 掌握客戶服務(wù)溝通技巧
- 聲音考古方法論探索-洞察闡釋
評(píng)論
0/150
提交評(píng)論