0% found this document useful (0 votes)
878 views5 pages

Math Cheatsheet - Opengl-Tutorial

This document provides a math cheatsheet for OpenGL 3.1 and later, summarizing key concepts like trigonometry, vectors, matrices, and common transformations. It defines trigonometric functions like pi, cosine, and sine. It explains vectors and homogeneous coordinates, how to calculate length, cross products, and dot products. It also summarizes how to add, subtract, and multiply vectors and matrices. Finally, it mentions normalization and common transformations.

Uploaded by

Gonçalo Palaio
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
878 views5 pages

Math Cheatsheet - Opengl-Tutorial

This document provides a math cheatsheet for OpenGL 3.1 and later, summarizing key concepts like trigonometry, vectors, matrices, and common transformations. It defines trigonometric functions like pi, cosine, and sine. It explains vectors and homogeneous coordinates, how to calculate length, cross products, and dot products. It also summarizes how to add, subtract, and multiply vectors and matrices. Finally, it mentions normalization and common transformations.

Uploaded by

Gonçalo Palaio
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

TutorialsforOpenGL3.

1andlater

MathCheatsheet

Trigonometry Pi Cosinus&Sinus Unitcircle Vectors Homogeneouscoordinates Length Crossproduct Dotproduct Additionandsubstraction Multiplication Normalization Matrices MatrixMatrixmultiplication MatrixVectormultiplication UsualTransformations

Trigonometry
Pi
constfloatpi=3.14159265f//butaninfinityofdigitsinreality

Cosinus&Sinus

(Fromhttp://commons.wikimedia.org/wiki/User:Geek3,underGNUFreeDocumentationLicense)

Unitcircle

(Modifiedfromhttp://en.wikipedia.org/wiki/User:GustavbunderCrativeCommons3.0)
tisanangleinradians. 0radians=0degrees 180degrees=Piradians 360degrees(fullcircle)=2*Piradians 90degrees=Pi/2radians

Vectors
ALWAYSknowinwhichcoordinatesyourvectoris.Seesection3fordetails.

Homogeneouscoordinates
A3Dvectoris(x,y,z),butahomogeneous3Dvectoris(x,y,z,w).

w=0:itsadirection w=1:itsaposition else:itmaystillbecorrect,butyoudbetterknowwhatyouredoing.


Youcanonlymultiplya44matrixwithahomogeneousvector.

Length
Justlikecartesiandistance:sqrt(x+y+z).wdoesntcount.

Crossproduct

(Modifiedfromhttp://en.wikipedia.org/wiki/User:Acdx,formerimageunderCreativeCommons3.0)
TheXisthenotationforthecrossproduct.length(axb)==length(a)*length(b),soyoumaywanttonormalize()theresult.

Dotproduct

(fromhttp://en.wikipedia.org/wiki/File:Dot_Product.svg)
A.B=length(A)*cos(Theta),butmostlikelycomputedasA.x*B.x+A.y*B.y+A.z*B.z

Additionandsubstraction
compontentwise:

rsx=Ax+Bx e. . . rsy=Ay+By e. . . .. .

Multiplication
compontentwise:

rsx=Ax*Bx e. . . rsy=Ay*By e. . .

.. .

Normalization
Dividethevectorbyitslength:

nraieVco =vc*(10 /vclnt( ) omlzdetr e .f e.egh)

Matrices
MatrixMatrixmultiplication
exampleforatranslationmatrix:

MatrixVectormultiplication

UsualTransformations

butinyourshaders,youcanalsorepresentyourvectorsintangentspace.Andinimagespacewhenyoudoposteffects.

Remark?Question?Bugreport?Feelfreetocontactusatcontact@opengltutorial.org CelineThemeProudlypoweredbyWordPress.

MultilingualWordPressbyICanLocalize

You might also like