V této kapitole je seznam matematických funkcí Direct3DX (což je jakýsi toolkit pro Direct3D (DirectXGraphics), jistá obdoba knihovny GLUT pro OpenGL), spolu s popisem matematiky, kterou tyto funkce provádí.
Upozorňuji, že toto není oficiální dokumentace k Direct3DX (ta se nalézá někde na MSDN).
Out = V1 + V2
Out = V1 + f⋅(V2−V1) + g⋅(V3−V1)
/ | 0 | 1 | 0 | 0 | \ | / | V1 | \ | |
| | | | | | | | ||||||
| | −0,5 | 0 | 0,5 | 0 | | | | | V2 | | | |
Out = (1,s,s²,s³) | | | | | | | | | |||||
| | 1 | −2,5 | 2 | −0,5 | | | | | V3 | | | |
| | | | | | | | ||||||
\ | −0,5 | 1,5 | −1,5 | 0,5 | / | \ | V4 | / |
Result = U ⋅ V = ∑iUiVi
/ | 1 | 0 | 0 | 0 | \ | / | V1 | \ | |
| | | | | | | | ||||||
| | 0 | 0 | 1 | 0 | | | | | V2 | | | |
Out = (1,s,s²s³) | | | | | | | | | |||||
| | −3 | 3 | −2 | −1 | | | | | T1 | | | |
| | | | | | | | ||||||
\ | 2 | −2 | 1 | 1 | / | \ | T2 | / |
Result = |V| = √(∑iVi²)
Result = |V|² = ∑iVi²
Out = V1 + s(V2−V1);
Outi = max(Ui, Vi)
Outi = min(Ui, Vi)
Out = 1⁄|V|⋅V
Out = sV
Out = V1 − V2
Result = UxVy − UyVx
a = (Vx, Vy, 0, 1)
b = (a×M)T
Out = (bx, by)
a = (Vx, Vy, 0, 1)
b = (a×M)T
Out = 1⁄bw(bx, by)
a = (Vx, Vy, 0, 0)
b = (a×M)T
Out = (bx, by)
Out = V1 × V2
a = (Vx, Vy, Vz, 1)
b = a×World×View×Proj
c = b⁄bw
Outx = ViewportX + ViewportWidth*(1+cx)/2
Outy = ViewportY + ViewportHeight*(1-cy)/2
Outz = ViewportMinZ + cz*(ViewportMaxZ-ViewportMinZ)
a = (Vx, Vy, Vz, 1)
b = (a×M)T
Out = (bx, by, bz)
a = (Vx, Vy, Vz, 1)
b = (a×M)T
Out = 1⁄bw(bx, by, bz)
a = (Vx, Vy, Vz, 0)
b = (a×M)T
Out = (bx, by, bz)
M = (World×View×Proj)−1
ax = (Vx-Viewportx)*2/ViewportWidth - 1
ay = 1 - (Vy-Viewporty)*2/ViewportHeight
az = (Vz-ViewportMinZ)/(ViewportMaxZ-ViewportMinZ)
aw = 1
b = (a×M)T
Out = 1⁄bw(bx, by, bz)
a = VxWy − VyWx
b = VxWz − VzWx
c = VxWw − VwWx
d = VyWz − VzWy
e = VyWw − VwWy
f = VzWw − VwWz
Outx = fUy − eUz + dUw
Outy = fUx + cUz − bUw
Outz = eUx − cUy + aUw
Outw = dUx + bUy − aUz
Out = (V×M)T
/ | s(2(ry² + rz²) − 1) | 2s(rxry + rzrw) | 2s(rxrz − ryrw) | 0 | \ | |
| | | | |||||
| | 2s(rxry − rzrw) | s(2(rx² + rz²) − 1) | 2s(ryrz + rxrw) | 0 | | | |
Out = | | | | | ||||
| | 2s(rxrz + ryrw) | 2s(ryrz − rxrw) | s(2(rx² + ry²) − 1) | 0 | | | |
| | | | |||||
\ | tx+2(cxry²+cxrz²−cyrxry+cyrzrw−czrxrz−czryrw) | ty+2(cyrx²+cyrz²−cxrxry−cxrzrw−czryrz+czrxrw) | tz+2(czrx²+czry²−cxrxrz+cxryrw−cyryrz−cyrxrw) | 1 | / |
Result = det M
/ | 1 | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | 1 | 0 | 0 | | | |
Out = E = | | | | | ||||
| | 0 | 0 | 1 | 0 | | | |
| | | | |||||
\ | 0 | 0 | 0 | 1 | / |
D = det M
Out = M−1
Result = M≡E
v = Normalized(Eye−At)
l = Up×v
u = v×l
/ | lx | ux | vx | 0 | \ | |
| | | | |||||
| | ly | uy | vy | 0 | | | |
Out = | | | | | ||||
| | lz | uz | vz | 0 | | | |
| | | | |||||
\ | −l⋅Eye | −u⋅Eye | −v⋅Eye | 1 | / |
v = Normalized(At−Eye)
r = Up×v
u = v×r
/ | rx | ux | vx | 0 | \ | |
| | | | |||||
| | ry | uy | vy | 0 | | | |
Out = | | | | | ||||
| | rz | uz | vz | 0 | | | |
| | | | |||||
\ | −r⋅Eye | −u⋅Eye | −v⋅Eye | 1 | / |
Out = M1×M2
Q = (f−n)−1
/ | 2⁄w | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | 2⁄h | 0 | 0 | | | |
Out = | | | | | ||||
| | 0 | 0 | −Q | 0 | | | |
| | | | |||||
\ | 0 | 0 | −Qn | 1 | / |
Q = (f−n)−1
/ | 2⁄w | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | 2⁄h | 0 | 0 | | | |
Out = | | | | | ||||
| | 0 | 0 | Q | 0 | | | |
| | | | |||||
\ | 0 | 0 | −Qn | 1 | / |
Q = (f−n)−1
w = r−l
h = b−t
/ | 2⁄w | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | 2⁄h | 0 | 0 | | | |
Out = | | | | | ||||
| | 0 | 0 | −Q | 0 | | | |
| | | | |||||
\ | −(r+l)⁄2 | −(t+b)⁄2 | −Qn | 1 | / |
Q = (f−n)−1
w = r−l
h = b−t
/ | 2⁄w | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | 2⁄h | 0 | 0 | | | |
Out = | | | | | ||||
| | 0 | 0 | Q | 0 | | | |
| | | | |||||
\ | −(r+l)⁄2 | −(t+b)⁄2 | −Qn | 1 | / |
Q = (f−n)−1
/ | 2⁄w | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | 2⁄h | 0 | 0 | | | |
Out = | | | | | ||||
| | 0 | 0 | −Qf | −1 | | | |
| | | | |||||
\ | 0 | 0 | −Qnf | 0 | / |
Q = (f−n)−1
/ | 2⁄w | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | 2⁄h | 0 | 0 | | | |
Out = | | | | | ||||
| | 0 | 0 | Qf | 1 | | | |
| | | | |||||
\ | 0 | 0 | −Qnf | 0 | / |
Q = (f−n)−1
y = cotg(Fovy)⁄2
/ | y⁄Aspect | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | y | 0 | 0 | | | |
Out = | | | | | ||||
| | 0 | 0 | −Qf | −1 | | | |
| | | | |||||
\ | 0 | 0 | −Qnf | 0 | / |
Q = (f−n)−1
y = cotg(Fovy)⁄2
/ | y⁄Aspect | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | y | 0 | 0 | | | |
Out = | | | | | ||||
| | 0 | 0 | Qf | 1 | | | |
| | | | |||||
\ | 0 | 0 | −Qnf | 0 | / |
Q = (f−n)−1
w = r−l
h = b−t
/ | 2⁄w | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | 2⁄h | 0 | 0 | | | |
Out = | | | | | ||||
| | (r+l)⁄w | (t+b)⁄h | −Qf | −1 | | | |
| | | | |||||
\ | 0 | 0 | −Qnf | 0 | / |
Q = (f−n)−1
w = r−l
h = b−t
/ | 2⁄w | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | 2⁄h | 0 | 0 | | | |
Out = | | | | | ||||
| | −(r+l)⁄w | −(t+b)⁄h | Qf | 1 | | | |
| | | | |||||
\ | 0 | 0 | −Qnf | 0 | / |
(a,b,c,d) = (Planea,Planeb,Planec,Planed)⁄√(Planea²+Planeb²+Planec²)
/ | 1−2a² | −2ba | −2ca | 0 | \ | |
| | | | |||||
| | −2ab | 1−2b² | −2cb | 0 | | | |
Out = | | | | | ||||
| | −2ac | −2bc | 1−2c² | 0 | | | |
| | | | |||||
\ | −2ad | −2bd | −2cd | 1 | / |
s = sin Angle
c = cos Angle
d = 1−c
(x,y,z) = V
/ | dx²+c | dxy+zs | dxz−ys | 0 | \ | |
| | | | |||||
| | dxy−zs | dy²+c | dyz+xs | 0 | | | |
Out = | | | | | ||||
| | dxy+ys | dyz−xs | dz²+c | 0 | | | |
| | | | |||||
\ | 0 | 0 | 0 | 1 | / |
(x,y,z,w) = Q
/ | 1−2y²−2z² | 2xy+2zw | 2xz−2yw | 0 | \ | |
| | | | |||||
| | 2xy−2zw | 1−2x²−2z² | 2yz+2xw | 0 | | | |
Out = | | | | | ||||
| | 2xz+2yw | 2yz−2xw | 1−2x²−2y² | 0 | | | |
| | | | |||||
\ | 0 | 0 | 0 | 1 | / |
s = sin Angle
c = cos Angle
/ | 1 | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | c | s | 0 | | | |
Out = | | | | | ||||
| | 0 | −s | c | 0 | | | |
| | | | |||||
\ | 0 | 0 | 0 | 1 | / |
s = sin Angle
c = cos Angle
/ | c | 0 | −s | 0 | \ | |
| | | | |||||
| | 0 | 1 | 0 | 0 | | | |
Out = | | | | | ||||
| | s | 0 | c | 0 | | | |
| | | | |||||
\ | 0 | 0 | 0 | 1 | / |
(sa,sb,sc) = sin (Roll, Pitch, Yaw)
(ca,cb,cc) = cos (Roll, Pitch, Yaw)
/ | ca⋅cc+sa⋅sb⋅sc | −sa⋅cc+ca⋅sb⋅sc | cb⋅sc | 0 | \ | |
| | | | |||||
| | sa⋅cb | ca⋅cb | −sb | 0 | | | |
Out = | | | | | ||||
| | −ca⋅sc+sa⋅sb⋅cc | sa⋅sc+ca⋅sb⋅cc | cb⋅cc | 0 | | | |
| | | | |||||
\ | 0 | 0 | 0 | 1 | / |
s = sin Angle
c = cos Angle
/ | c | s | 0 | 0 | \ | |
| | | | |||||
| | −s | c | 0 | 0 | | | |
Out = | | | | | ||||
| | 0 | 0 | 1 | 0 | | | |
| | | | |||||
\ | 0 | 0 | 0 | 1 | / |
/ | x | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | y | 0 | 0 | | | |
Out = | | | | | ||||
| | 0 | 0 | z | 0 | | | |
| | | | |||||
\ | 0 | 0 | 0 | 1 | / |
(a,b,c,d) = (Planea,Planeb,Planec,Planed)⁄√(Planea²+Planeb²+Planec²)
(x,y,z,w) = Light
f = Lightx⋅Planea + Lighty⋅Planeb + Lightz⋅Planec + Lightw⋅Planed
/ | f−xa | −ya | −za | −wa | \ | |
| | | | |||||
| | −xb | f−yb | −zb | −wb | | | |
Out = | | | | | ||||
| | −xc | −yc | f−zc | −wc | | | |
| | | | |||||
\ | −xd | −yd | −zd | f−wd | / |
D3DXMatrixTranslation(A, -Scenterx, -Scentery, -Scenterz)
D3DXMatrixScaling(B, Scalingx, Scalingy, Scalingz)
D3DXMatrixRotationQuaternion(C, Srot)
u = Scenter − Rotcenter
D3DXMatrixTranslation(D, ux, uy, uz)
D3DXMatrixRotationQuaternion(E, Rot)
v = Rotcenter + Trans
D3DXMatrixTranslation(F, vx, vy, vz)
Out = A×CT×B×C×D×E×F
/ | 1 | 0 | 0 | 0 | \ | |
| | | | |||||
| | 0 | 1 | 0 | 0 | | | |
Out = | | | | | ||||
| | 0 | 0 | 1 | 0 | | | |
| | | | |||||
\ | x | y | z | 1 | / |
Out = MT
Result = (Pa, Pb, Pc, Pd)⋅V
Result = (Pa, Pb, Pc)⋅V + Pd
Result = (Pa, Pb, Pc)⋅V
n = (Planea, Planeb, Planec)
d = V − U
Out = U − d⋅(Pd + n⋅U)⁄(d⋅n) [iff d⋅n ≠ 0]
Planea = Nx
Planeb = Ny
Planec = Nz
Planed = −N⋅P
q = 1⁄√(Pa² + Pb² + Pc²)
Outa = q⋅Pa
Outb = q⋅Pb
Outc = q⋅Pc
Outd = q⋅Pd
v = (B − A) × (C − A)
n = 1⁄|v| v
Outa = nx
Outb = ny
Outc = nz
Outd = −n⋅A
Q = P⁄|P|
u = (Qa, Qb, Qc, 0)
D = Qd
A = (−Dux, −Duy, −Duz, 1)
B = A×M
v = u×M
q = 1⁄|v|
Outa = qvx
Outb = qvy
Outc = qvz
Outd = −qv⋅B