Guten Morgen Gunnar Bittersmann,
Nein. Sprich: Matrixprodukt.
Das Kreuzprodukt ist was ganz anderes.
Richtig, mein Fehler.
So kleines Update:
function vectorRotationXYZ($vector, $beta, $gamma, $delta)
{
$rotation_XYZ = [
"rotX" => [ "x" => ["x" => 1, "y" => 0, "z" => 0 ] ,
"y" => ["x" => 0, "y" => cos($beta), "z" => -sin($beta) ] ,
"z" => ["x" => 0, "y" => sin($beta), "z" => cos($beta) ]],
"rotY" => [ "x" => ["x" => cos($gamma), "y" => 0, "z" => sin($gamma) ] ,
"y" => ["x" => 0, "y" => 1, "z" => 0 ] ,
"z" => ["x" => -sin($gamma),"y" => 0, "z" => cos($gamma) ]],
"rotZ" => [ "x" => ["x" => cos($delta), "y" => -sin($delta), "z" => 0 ] ,
"y" => ["x" => sin($delta), "y" => cos($delta), "z" => 0 ] ,
"z" => ["x" => 0, "y" => 0, "z" => 1 ]]
];
$result_vector = $vector;
$interim_result_vector = ["x" => 0, "y" => 0, "z" => 0];
foreach($rotation_XYZ as $matrix => $rotation_matrix)
{
foreach($rotation_matrix as $row_key => $matrix_row)
{
foreach($matrix_row as $multiplicator_key => $multiplicator)
{
$interim_result_vector[$row_key] += $multiplicator * $result_vector[$multiplicator_key];
}
}
$result_vector = $interim_result_vector;
$interim_result_vector = ["x" => 0, "y" => 0, "z" => 0];
}
return $result_vector;
}
Ich muss sagen ich finde die Umsetzung sehr Elegant.
Gruß
Jo