Voilà le code que j'ai écris, c assez long et si je pouvais tout regrouper en une seule fonction ca serait cool
Option Explicit
Function chgt_repere_X(ByVal x As Double, ByVal y As Double, ByVal z As Double, ByVal PosX As Double, ByVal PosY As Double, ByVal PosZ As Double, ByVal RotX As Double, ByVal RotY As Double, ByVal RotZ As Double) As Variant
Dim mat_pass(3, 3), vect(3) As Double
Dim A As Double
Dim j As Double
A = 0
mat_pass(0, 0) = Cos(RotZ) * Cos(RotY)
mat_pass(0, 1) = Cos(RotZ) * Sin(RotY) * Sin(RotX) + Cos(RotX) * Sin(RotZ)
mat_pass(0, 2) = -Cos(RotZ) * Sin(RotY) * Cos(RotX) + Sin(RotX) * Sin(RotZ)
mat_pass(0, 3) = PosX
mat_pass(1, 0) = -Cos(RotY) * Sin(RotZ)
mat_pass(1, 1) = -Sin(RotZ) * Sin(RotY) * Sin(RotX) + Cos(RotX) * Cos(RotZ)
mat_pass(1, 2) = Sin(RotZ) * Sin(RotY) * Cos(RotX) + Cos(RotZ) * Sin(RotX)
mat_pass(1, 3) = PosY
mat_pass(2, 0) = Sin(RotY)
mat_pass(2, 1) = Cos(RotY) * Sin(RotX)
mat_pass(2, 2) = Cos(RotY) * Cos(RotX)
mat_pass(2, 3) = PosZ
mat_pass(3, 0) = 0
mat_pass(3, 1) = 0
mat_pass(3, 2) = 0
mat_pass(3, 3) = 1
vect(0) = x
vect(1) = y
vect(2) = z
vect(3) = 1
For j = 0 To 3
A = A + mat_pass(0, j) * vect(j)
Next j
chgt_repere_X = A
End Function
Function chgt_repere_Y(ByVal x As Double, ByVal y As Double, ByVal z As Double, ByVal PosX As Double, ByVal PosY As Double, ByVal PosZ As Double, ByVal RotX As Double, ByVal RotY As Double, ByVal RotZ As Double) As Variant
Dim mat_pass(3, 3), vect(3) As Double
Dim B As Double
Dim j As Double
B = 0
mat_pass(0, 0) = Cos(RotZ) * Cos(RotY)
mat_pass(0, 1) = Cos(RotZ) * Sin(RotY) * Sin(RotX) + Cos(RotX) * Sin(RotZ)
mat_pass(0, 2) = -Cos(RotZ) * Sin(RotY) * Cos(RotX) + Sin(RotX) * Sin(RotZ)
mat_pass(0, 3) = PosX
mat_pass(1, 0) = -Cos(RotY) * Sin(RotZ)
mat_pass(1, 1) = -Sin(RotZ) * Sin(RotY) * Sin(RotX) + Cos(RotX) * Cos(RotZ)
mat_pass(1, 2) = Sin(RotZ) * Sin(RotY) * Cos(RotX) + Cos(RotZ) * Sin(RotX)
mat_pass(1, 3) = PosY
mat_pass(2, 0) = Sin(RotY)
mat_pass(2, 1) = Cos(RotY) * Sin(RotX)
mat_pass(2, 2) = Cos(RotY) * Cos(RotX)
mat_pass(2, 3) = PosZ
mat_pass(3, 0) = 0
mat_pass(3, 1) = 0
mat_pass(3, 2) = 0
mat_pass(3, 3) = 1
vect(0) = x
vect(1) = y
vect(2) = z
vect(3) = 1
For j = 0 To 3
B = B + mat_pass(1, j) * vect(j)
Next j
chgt_repere_Y = B
End Function
Function chgt_repere_Z(ByVal x As Double, ByVal y As Double, ByVal z As Double, ByVal PosX As Double, ByVal PosY As Double, ByVal PosZ As Double, ByVal RotX As Double, ByVal RotY As Double, ByVal RotZ As Double) As Variant
Dim mat_pass(3, 3), vect(3) As Double
Dim C As Double
Dim j As Double
C = 0
mat_pass(0, 0) = Cos(RotZ) * Cos(RotY)
mat_pass(0, 1) = Cos(RotZ) * Sin(RotY) * Sin(RotX) + Cos(RotX) * Sin(RotZ)
mat_pass(0, 2) = -Cos(RotZ) * Sin(RotY) * Cos(RotX) + Sin(RotX) * Sin(RotZ)
mat_pass(0, 3) = PosX
mat_pass(1, 0) = -Cos(RotY) * Sin(RotZ)
mat_pass(1, 1) = -Sin(RotZ) * Sin(RotY) * Sin(RotX) + Cos(RotX) * Cos(RotZ)
mat_pass(1, 2) = Sin(RotZ) * Sin(RotY) * Cos(RotX) + Cos(RotZ) * Sin(RotX)
mat_pass(1, 3) = PosY
mat_pass(2, 0) = Sin(RotY)
mat_pass(2, 1) = Cos(RotY) * Sin(RotX)
mat_pass(2, 2) = Cos(RotY) * Cos(RotX)
mat_pass(2, 3) = PosZ
mat_pass(3, 0) = 0
mat_pass(3, 1) = 0
mat_pass(3, 2) = 0
mat_pass(3, 3) = 1
vect(0) = x
vect(1) = y
vect(2) = z
vect(3) = 1
For j = 0 To 3
C = C + mat_pass(2, j) * vect(j)
Next j
chgt_repere_Z = C
End Function