當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Matrix::mult方法代碼示例

本文整理匯總了PHP中Matrix::mult方法的典型用法代碼示例。如果您正苦於以下問題:PHP Matrix::mult方法的具體用法?PHP Matrix::mult怎麽用?PHP Matrix::mult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Matrix的用法示例。


在下文中一共展示了Matrix::mult方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Matrix

$T = new Matrix(array('preset' => Matrix::TRANSLATION, 'vtc' => $vtc));
print $T . PHP_EOL . PHP_EOL;
print 'A scale matrix is no big deal.' . PHP_EOL;
$S = new Matrix(array('preset' => Matrix::SCALE, 'scale' => 10.0));
print $S . PHP_EOL . PHP_EOL;
print 'A Rotation along the OX axis :' . PHP_EOL;
$RX = new Matrix(array('preset' => Matrix::RX, 'angle' => M_PI_4));
print $RX . PHP_EOL . PHP_EOL;
print 'Or along the OY axis :' . PHP_EOL;
$RY = new Matrix(array('preset' => Matrix::RY, 'angle' => M_PI_2));
print $RY . PHP_EOL . PHP_EOL;
print 'Do a barrel roll !' . PHP_EOL;
$RZ = new Matrix(array('preset' => Matrix::RZ, 'angle' => 2 * M_PI));
print $RZ . PHP_EOL . PHP_EOL;
print 'The bad guy now, the projection matrix : 3D to 2D !' . PHP_EOL;
print 'The values are arbitray. We\'ll decipher them in the next exercice.' . PHP_EOL;
$P = new Matrix(array('preset' => Matrix::PROJECTION, 'fov' => 60, 'ratio' => 640 / 480, 'near' => 1.0, 'far' => -50.0));
print $P . PHP_EOL . PHP_EOL;
print 'Matrices are so awesome, that they can be combined !' . PHP_EOL;
print 'This is a model matrix that scales, then rotates around OY axis,' . PHP_EOL;
print 'then rotates around OX axis and finally translates.' . PHP_EOL;
print 'Please note the reverse operations order. It\'s not an error.' . PHP_EOL;
$M = $T->mult($RX)->mult($RY)->mult($S);
print $M . PHP_EOL . PHP_EOL;
print 'What can you do with a matrix and a vertex ?' . PHP_EOL;
$vtxA = new Vertex(array('x' => 1.0, 'y' => 1.0, 'z' => 0.0));
print $vtxA . PHP_EOL;
print $M . PHP_EOL;
print 'Transform the damn vertex !' . PHP_EOL;
$vtxB = $M->transformVertex($vtxA);
print $vtxB . PHP_EOL . PHP_EOL;
開發者ID:samiateber,項目名稱:42,代碼行數:31,代碼來源:main_03.php


注:本文中的Matrix::mult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。