Bah les matrices de rotations 4d tu les as sur wikipedia (attention par contre, y en a une fausse sur la page FR si je me souviens bien), mais tu peux les calculer toi même aussi, c'est pas bien compliqué (j'y étais arrivé au lycée, sans y connaitre grand chose).
Mais oui en 2d une rotation est autour d'un point, en 3d autour d'un axe, et en 4d autour d'un plan.
Si ça t'interesse, de vielles sources de GML bien moche:
Init
Code : Tout sélectionner
xoff = 320
yoff = 240
zoff = 500
aa = 0
bb = 0
cc = 0
ort4 = 1
ort3 = 1
load_w4("tesseract.w4",100) // on charge notre hypercube
Code : Tout sélectionner
aa += keyboard_check(vk_up) - keyboard_check(vk_down)
bb += keyboard_check(vk_left) - keyboard_check(vk_right)
cc += keyboard_check(vk_numpad4) - keyboard_check(vk_numpad6)
axy = mouse_x
ayz = mouse_y
azx = 0//mouse_y
axw = aa
ayw = bb
azw = cc
cxy = lengthdir_x(1, axy) sxy = lengthdir_y(1, axy)
cyz = lengthdir_x(1, ayz) syz = lengthdir_y(1, ayz)
czx = lengthdir_x(1, azx) szx = lengthdir_y(1, azx)
cxw = lengthdir_x(1, axw) sxw = lengthdir_y(1, axw)
cyw = lengthdir_x(1, ayw) syw = lengthdir_y(1, ayw)
czw = lengthdir_x(1, azw) szw = lengthdir_y(1, azw)
//Matrice de rotation 4D
mat[0,0] = cxy*czx*cxw + sxy*syz*szx*cxw
mat[0,1] = sxy*cyz*cyw + cxy*czx*sxw*syw + sxy*syz*szx*sxw*syw
mat[0,2] = sxy*syz*czx*czw - cxy*szx*czw + cxy*czx*sxw*cyw*szw + sxy*syz*szx*sxw*cyw*szw - sxy*cyz*syw*szw
mat[0,3] = cxy*czx*sxw*cyw*czw + sxy*syz*szx*sxw*cyw*czw - sxy*cyz*syw*czw - sxy*syz*czx*szw + cxy*szx*szw
mat[1,0] = -sxy*czx*cxw + cxy*syz*szx*cxw
mat[1,1] = cxy*cyz*cyw - sxy*czx*sxw*syw + cxy*syz*szx*sxw*syw
mat[1,2] = sxy*szx*czw + cxy*syz*czx*czw - sxy*czx*sxw*cyw*szw + cxy*syz*szx*sxw*cyw*szw - cxy*cyz*syw*szw
mat[1,3] = -sxy*czx*sxw*cyw*czw + cxy*syz*szx*sxw*cyw*czw - cxy*cyz*syw*czw - sxy*szx*szw - cxy*syz*czx*szw
mat[2,0] = cyz*szx*cxw - sxw
mat[2,1] = -syz*cyw + cxw*syw + cyz*szx*sxw*syw
mat[2,2] = cyz*czx*czw + cxw*cyw*szw + cyz*szx*sxw*cyw*szw + syz*syw*szw
mat[2,3] = cxw*cyw*czw + cyz*szx*sxw*cyw*czw + syz*syw*czw - cyz*czx*szw
mat[3,0] = -sxw*cxw - sxw
mat[3,1] = cxw*syw
mat[3,2] = cxw*cyw*szw
mat[3,3] = cxw*cyw*czw
for(i=0 ; i<vcount ; i+=1)
{
rx = vx[i]*mat[0,0] + vy[i]*mat[0,1] + vz[i]*mat[0,2] + vt[i]*mat[0,3]
ry = vx[i]*mat[1,0] + vy[i]*mat[1,1] + vz[i]*mat[1,2] + vt[i]*mat[1,3]
rz = vx[i]*mat[2,0] + vy[i]*mat[2,1] + vz[i]*mat[2,2] + vt[i]*mat[2,3]
rt = vx[i]*mat[3,0] + vy[i]*mat[3,1] + vz[i]*mat[3,2] + vt[i]*mat[3,3]
toff = 480
s1 = 300
s2 = 320
zoff = 480
tx = rx*s1/(rt*ort4+toff)
ty = ry*s1/(rt*ort4+toff)
tz = rz*s1/(rt*ort4+toff)
px[i] = tx*s2/(tz*ort3+zoff) + xoff
py[i] = ty*s2/(tz*ort3+zoff) + yoff
}
draw_set_color(c_white)
for(i=0; i<lcount; i+=1)
draw_line(px[ ls[i] ], py[ ls[i] ], px[ le[i] ], py[ le[i] ])
draw_text(16, 16, "4, 6, et les fleches pour les rotations d'axes xw, yw, et zw")
Code : Tout sélectionner
f = file_text_open_read(argument0)
scale = argument1
str = file_text_read_string(f)
while( !string_count("VertexList",str) )
{
file_text_readln(f)
str = file_text_read_string(f)
}
str = string_delete(str, 1, string_length("VertexList")+1)
str = string_replace_all(str, ":", "")
vcount = real(str)
for(i=0 ; i<vcount ; i+=1)
{
file_text_readln(f)
str = file_text_read_string(f)
while(!string_length(str)) {
file_text_readln(f)
str = file_text_read_string(f)
}
str = string_delete(str,1,1)
str = string_replace_all(str, " ", "")
for(j=0 ; j<4 ; j+=1)
{
pos = string_pos(",", str)
if(!pos)
pos = string_length(str)
s = string_copy(str, 1, pos-(j<3))
v[j] = real(s)
str = string_delete(str, 1, pos)
}
vx[i] = v[0]*scale
vy[i] = v[1]*scale
vz[i] = v[2]*scale
vt[i] = v[3]*scale
}
while( !string_count("EdgeList",str) )
{
file_text_readln(f)
str = file_text_read_string(f)
}
str = string_delete(str, 1, string_length("EdgeList")+1)
str = string_replace_all(str, ":", "")
lcount = real(str)
for(i=0 ; i<lcount ; i+=1)
{
file_text_readln(f)
str = file_text_read_string(f)
while(!string_length(str)) {
file_text_readln(f)
str = file_text_read_string(f)
}
str = string_delete(str,1,1)
str = string_replace_all(str, " ", "")
for(j=0 ; j<2 ; j+=1)
{
pos = string_pos("/", str)
if(string_count(",", str))
pos = string_pos(",", str)
s = string_copy(str, 1, pos-1)
l[j] = real(s)
str = string_delete(str, 1, pos)
}
ls[i] = l[0]
le[i] = l[1]
}
file_text_close(f)
Code : Tout sélectionner
# This file contains the 4D hypercube. In the initial display, the inner
# cube, the outer cube, and the connections are all colored differently.
DepthCueLevels 8
ColorNear 255 105 255
ColorFar 0 0 0
DepthNear 1.5
DepthFar 4.5
From4: 4.0, 0.0, 0.0, 0.0
To4: 0.0, 0.0, 0.0, 0.0
Up4: 0.0, 1.0, 0.0, 0.0
Over4: 0.0, 0.0, 1.0, 0.0
Vangle4: 45.0
From3: 2.0, 0.5, 3.0
To3: 0.0, 0.0, 0.0
Up3: 0.0, 1.0, 0.0
Vangle3: 45.0
# The hypercube spans the +-1 unit cube and is centered at the origin.
VertexList 16:
-1,-1,-1,-1
1,-1,-1,-1
1, 1,-1,-1
-1, 1,-1,-1
-1,-1, 1,-1
1,-1, 1,-1
1, 1, 1,-1
-1, 1, 1,-1
-1,-1,-1, 1
1,-1,-1, 1
1, 1,-1, 1
-1, 1,-1, 1
-1,-1, 1, 1
1,-1, 1, 1
1, 1, 1, 1
-1, 1, 1, 1
EdgeList 32:
0, 1 / 3
1, 2 / 2
2, 3 / 3
3, 0 / 5
4, 5 / 3
5, 6 / 2
6, 7 / 3
7, 4 / 5
0, 4 / 5
1, 5 / 2
2, 6 / 2
3, 7 / 5
8, 9 / 3
9,10 / 2
10,11 / 3
11, 8 / 5
12,13 / 3
13,14 / 2
14,15 / 3
15,12 / 5
8,12 / 5
9,13 / 2
10,14 / 2
11,15 / 5
0, 8 / 5
1, 9 / 2
2,10 / 2
3,11 / 5
4,12 / 5
5,13 / 2
6,14 / 2
7,15 / 5