Working with Graphic Elements > Classes > Matrix4 > Matrix4.rotate
rotate(alpha: number, v: PP.Vector3);
alpha. Rotation angle in medians.
v. Vector.
The rotate method rotates model and view matrix.
To execute this example, in the HEAD tag of HTML page specify links to the following JS and CSS files: PP.js, PP.GraphicBase.js. Create a new matrix:
// Create a matrix matrix = new PP.Matrix4([ 4.717621803283691, 0, 0, 0, 0, 10.385396957397461, 0, 0, 0, 0, -1.0000020265579224, -1, 0, 0, -0.002000001957640052, 0 ]); // Create a vector vector = new PP.Vector3(1, 0.5, 2); // Rotate matrix matrix.rotate(1, vector); // Get matrix values matrix.getData(); // -> // [-4.499267578125, 19.86509132385254, -0.4986609220504761, -0.4986599087715149, // -6.855144023895264, -13.485318183898926, -1.3011713027954102, -1.30116868019104, // 6.322230815887451, -3.964867115020752, -0.4253787398338318, -0.42537787556648254, // 0, 0, -0.002000001957640052, 0]
After executing the example the matrix is rotated.
See also: