How to use mul4x4 method in wpt

Best JavaScript code snippet using wpt

orbitcam.js

Source:orbitcam.js Github

copy

Full Screen

...224 // If the position of the camera is sitting at the orbit point,225 // we don't actually move the camera.226 if(V3.equals(pos, orbitPoint)){227 var rotMat = M4x4.makeRotate(angle, left);228 dir = V3.normalize(V3.mul4x4(rotMat, dir)); 229 up = V3.normalize(V3.cross(dir, left));230 }231 else{232 // Get the position relative to orbit point.233 pos = V3.sub(pos, orbitPoint);234 var rotMat = M4x4.makeRotate(angle, left);235 236 // The position of the camera will actually change when pitching.237 var newpos = V3.mul4x4(rotMat, pos);238 pos = V3.add(newpos, orbitPoint);239 240 dir = V3.normalize(V3.sub(orbitPoint, pos));241 up = V3.normalize(V3.cross(dir, left));242 left = V3.normalize(V3.cross(up, dir));243 }244 };245 246 /**247 Yaw the camera about the global up axis.248 249 @param {Number} angle in radians250 */251 this.yaw = function(angle){252 if(V3.equals(pos, orbitPoint)){253 254 var rotMat = M4x4.makeRotate(angle, [0,1,0]);255 256 left = V3.normalize(V3.mul4x4(rotMat, left));257 up = V3.normalize(V3.mul4x4(rotMat, up));258 dir = V3.normalize(V3.cross(left, up));259 }260 else{261 var camPosOrbit = V3.sub(pos, orbitPoint);262 // Create a rotation matrix based on location and angle.263 // we will rotate about the global up axis.264 var rotMat = M4x4.makeRotate(angle, [0,1,0]);265 var newpos = V3.mul4x4(rotMat, camPosOrbit);266 pos = V3.add(newpos, orbitPoint);267 268 dir = V3.normalize(V3.sub(orbitPoint, pos));269 up = V3.normalize(V3.mul4x4(rotMat, up));270 left = V3.normalize(V3.cross(up, dir));271 }272 };273 274 275 /**276 Create a new orbit point.277 278 @param {Array} op New orbit point279 */280 this.setOrbitPoint = function(op){281 orbitPoint = V3.clone(op);282 283 // get the distance the camera was from the orbit point....

Full Screen

Full Screen

SV3DView.mc

Source:SV3DView.mc Github

copy

Full Screen

...34 m = Matrix.getEye(4);35 // move the origin to the center of the screen36 var cx = System.getDeviceSettings().screenWidth*0.5;37 var cy = System.getDeviceSettings().screenHeight*0.5;38 m = Matrix.mul4x4(m, Graphics3D.getTranslate(cx, cy+25, 0.0)); // a bit below the center39 // scale so that approx. -2.0 .. +2.0 is equivalent to the screen height,40 // reverse y coordinates because the screen counts from top to bottom41 m = Matrix.mul4x4(m, Graphics3D.getScale(cy*0.5, -cy*0.5, 1.0));42 // perspective projection43 m = Matrix.mul4x4(m, Graphics3D.getPerspective(Math.toRadians(20.0), 1.0, 1.0, 1000.0));44 mG3D.setProjectionMatrix(m);45 mG3D.updateMatrix();46 }47 /**48 * Draw the screen49 */50 function onUpdate(dc) {51 var width = dc.getWidth();52 var height = dc.getHeight();53 54 // clear the screen55 dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK);56 dc.clear();57 // title58 dc.setColor(Graphics.COLOR_GREEN, Graphics.COLOR_TRANSPARENT);59 dc.drawText(width / 2, 3, Graphics.FONT_LARGE, mTitle, Graphics.TEXT_JUSTIFY_CENTER);60 if (mData == null) {61 // no data (yet)62 dc.setColor(Graphics.COLOR_RED, Graphics.COLOR_TRANSPARENT);63 dc.drawText(width / 2, 30, Graphics.FONT_TINY, "No Sensor Data Available", Graphics.TEXT_JUSTIFY_CENTER);64 return;65 }66 // sensor data is in mData67 // calculate spherical coordinates68 var spR = Math.sqrt(mData[0]*mData[0] + mData[1]*mData[1] + mData[2]*mData[2]);69 var spTheta = Math.acos(mData[2]/spR);70 var spPhi = Math.atan2(mData[1], mData[0]);71 var spStr = "r="+spR.format("%.2f") + ", th="+Math.toDegrees(spTheta).format("%.1f") + "°, ph="+Math.toDegrees(spPhi).format("%.1f")+"°";72 73 // print data74 dc.setColor(Graphics.COLOR_YELLOW, Graphics.COLOR_TRANSPARENT);75 dc.drawText(width / 2, 30, Graphics.FONT_TINY, "Data: " + mData, Graphics.TEXT_JUSTIFY_CENTER);76 dc.drawText(width / 2, 50, Graphics.FONT_TINY, spStr, Graphics.TEXT_JUSTIFY_CENTER);77 // prepare 3D drawing78 mG3D.setDc(dc);79 // coordinate system (bright color is positive)80 dc.setColor(Graphics.COLOR_RED, Graphics.COLOR_TRANSPARENT);81 mG3D.drawLine([0.0,0.0,0.0], [ 1.0, 0.0, 0.0]);82 dc.setColor(Graphics.COLOR_DK_RED, Graphics.COLOR_TRANSPARENT);83 mG3D.drawLine([0.0,0.0,0.0], [-1.0, 0.0, 0.0]);84 dc.setColor(Graphics.COLOR_GREEN, Graphics.COLOR_TRANSPARENT);85 mG3D.drawLine([0.0,0.0,0.0], [ 0.0, 1.0, 0.0]);86 dc.setColor(Graphics.COLOR_DK_GREEN, Graphics.COLOR_TRANSPARENT);87 mG3D.drawLine([0.0,0.0,0.0], [ 0.0,-1.0, 0.0]);88 dc.setColor(Graphics.COLOR_BLUE, Graphics.COLOR_TRANSPARENT);89 mG3D.drawLine([0.0,0.0,0.0], [ 0.0, 0.0, 1.0]);90 dc.setColor(Graphics.COLOR_DK_BLUE, Graphics.COLOR_TRANSPARENT);91 mG3D.drawLine([0.0,0.0,0.0], [ 0.0, 0.0,-1.0]);92 // unit cube93 dc.setColor(Graphics.COLOR_ORANGE, Graphics.COLOR_TRANSPARENT);94 // square at z=-1.095 mG3D.drawPoly([[ 1.0, 1.0,-1.0], [ 1.0,-1.0,-1.0], [-1.0,-1.0,-1.0], [-1.0, 1.0,-1.0]], true);96 // square at z=+1.097 dc.setColor(Graphics.COLOR_YELLOW, Graphics.COLOR_TRANSPARENT);98 mG3D.drawPoly([[ 1.0, 1.0, 1.0], [ 1.0,-1.0, 1.0], [-1.0,-1.0, 1.0], [-1.0, 1.0, 1.0]], true);99 // connecting vertical corners100 dc.setColor(Graphics.COLOR_LT_GRAY, Graphics.COLOR_TRANSPARENT);101 mG3D.drawLine([ 1.0, 1.0, 1.0], [ 1.0, 1.0,-1.0]);102 mG3D.drawLine([ 1.0,-1.0, 1.0], [ 1.0,-1.0,-1.0]);103 mG3D.drawLine([-1.0,-1.0, 1.0], [-1.0,-1.0,-1.0]);104 mG3D.drawLine([-1.0, 1.0, 1.0], [-1.0, 1.0,-1.0]);105 // connectors from data to the axes106 dc.setColor(Graphics.COLOR_DK_GRAY, Graphics.COLOR_TRANSPARENT);107 mG3D.drawPoly([[mData[0]*0.001, 0.0, 0.0],108 [mData[0]*0.001, mData[1]*0.001, 0.0],109 [0.0, mData[1]*0.001, 0.0]], false);110 mG3D.drawLine([mData[0]*0.001, mData[1]*0.001, 0.0],111 [mData[0]*0.001, mData[1]*0.001, mData[2]*0.001]);112 // data113 dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);114 mG3D.drawLine([0,0,0], [mData[0]*0.001, mData[1]*0.001, mData[2]*0.001]);115 }116}117/**118 * Input (button presses) handler119 */120class SV3DDelegate extends Ui.BehaviorDelegate {121 var mView;122 function initialize(view) {123 BehaviorDelegate.initialize();124 mView = view;125 }126 function onNextPage() {127 mView.mG3D.mModel = Matrix.mul4x4(mView.mG3D.mModel, Graphics3D.getRotate(Math.PI*0.1, 0.0, 0.0, 1.0));128 mView.mG3D.updateMatrix();129 return true;130 }131 function onPreviousPage() {132 mView.mG3D.mModel = Matrix.mul4x4(mView.mG3D.mModel, Graphics3D.getRotate(-Math.PI*0.1, 0.0, 0.0, 1.0));133 mView.mG3D.updateMatrix();134 return true;135 }136 //function onSelect() {137 //}138 //function onBack() {139 //}140}...

Full Screen

Full Screen

Matrix.mc

Source:Matrix.mc Github

copy

Full Screen

...110 }111 /**112 * Matrix multiplication of two 4x4 matrices113 */114 function mul4x4(a, b) {115 var result = new [4*4];116 var sum;117 var x,y,i;118 for (x = 0; x < 4; x++) {119 for (y = 0; y < 4; y++) {120 sum = 0.0;121 for (i = 0; i < 4; i++) {122 sum += a[y*4+i] * b[i*4+x];123 }124 result[y*4+x] = sum;125 }126 }127 //System.println("mul4x4: " + a);128 //System.println("mul4x4: " + b);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt.js');2var a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];3var b = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];4var c = wpt.mul4x4(a,b);5console.log(c);6var wpt = require('wpt.js');7var a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];8var b = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];9var c = wpt.mul4x4(a,b);10console.log(c);11var wpt = require('wpt.js');12var a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];13var b = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];14var c = wpt.mul4x4(a,b);15console.log(c);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var m = wpt.mul4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);3console.log(m);4module.exports = {5 mul4x4: function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) {6 return a*e*i*m + b*f*j*n + c*g*k*o + d*h*l*p;7 }8};9exports.mul4x4 = function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) {10 return a*e*i*m + b*f*j*n + c*g*k*o + d*h*l*p;11}12exports.mul4x4 = function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) {13 return a*e*i*m + b*f*j*n + c*g*k*o + d*h*l*p;14}15exports.mul4x4 = function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) {16 return a*e*i*m + b*f*j*n + c*g*k*o + d*h*l*p;17}18exports.mul4x4 = function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var a = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]];3var b = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]];4var res = wptoolkit.mul4x4(a,b);5console.log(res);6var wptoolkit = require('wptoolkit');7var a = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]];8var b = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]];9var res = wptoolkit.mul4x4(a,b);10console.log(res);11var wptoolkit = require('wptoolkit');12var a = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]];13var b = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]];14var res = wptoolkit.mul4x4(a,b);15console.log(res);16var wptoolkit = require('wptoolkit');17var a = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]];18var b = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]];19var res = wptoolkit.mul4x4(a,b);20console.log(res);

Full Screen

Using AI Code Generation

copy

Full Screen

1var m = new wptMatrix4x4();2var m1 = new wptMatrix4x4();3var m2 = new wptMatrix4x4();4var m3 = new wptMatrix4x4();5var m4 = new wptMatrix4x4();6var m5 = new wptMatrix4x4();7var m6 = new wptMatrix4x4();8var m7 = new wptMatrix4x4();9var m8 = new wptMatrix4x4();10var m9 = new wptMatrix4x4();11var m10 = new wptMatrix4x4();12var m11 = new wptMatrix4x4();13var m12 = new wptMatrix4x4();14var m13 = new wptMatrix4x4();15var m14 = new wptMatrix4x4();16var m15 = new wptMatrix4x4();17var m16 = new wptMatrix4x4();18var m17 = new wptMatrix4x4();19var m18 = new wptMatrix4x4();20var m19 = new wptMatrix4x4();21var m20 = new wptMatrix4x4();22var m21 = new wptMatrix4x4();23var m22 = new wptMatrix4x4();24var m23 = new wptMatrix4x4();25var m24 = new wptMatrix4x4();26var m25 = new wptMatrix4x4();27var m26 = new wptMatrix4x4();28var m27 = new wptMatrix4x4();29var m28 = new wptMatrix4x4();30var m29 = new wptMatrix4x4();31var m30 = new wptMatrix4x4();32var m31 = new wptMatrix4x4();33var m32 = new wptMatrix4x4();34var m33 = new wptMatrix4x4();35var m34 = new wptMatrix4x4();36var m35 = new wptMatrix4x4();37var m36 = new wptMatrix4x4();38var m37 = new wptMatrix4x4();39var m38 = new wptMatrix4x4();40var m39 = new wptMatrix4x4();41var m40 = new wptMatrix4x4();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var matrix1 = [[1, 2, 3, 4], [5, 6, 7, 8], [0, 1, 2, 3], [4, 5, 6, 7]];3var matrix2 = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]];4var result = wptoolkit.mul4x4(matrix1, matrix2);5console.log(result);6var wptoolkit = require('wptoolkit');7var matrix1 = [[1, 2, 3, 4], [5, 6, 7, 8], [0, 1, 2, 3], [4, 5, 6, 7]];8var matrix2 = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]];9var result = wptoolkit.mul4x4(matrix1, matrix2);10console.log(result);11var wptoolkit = require('wptoolkit');

Full Screen

Using AI Code Generation

copy

Full Screen

1var mat = wpt.mul4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);2console.log(mat);3var mat = wpt.mul4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);4console.log(mat);5var mat = wpt.mul4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);6console.log(mat);7var mat = wpt.mul4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);8console.log(mat);9var mat = wpt.mul4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wp = wptools.page('Albert Einstein');3wp.get(function(err, resp) {4 console.log(wp.infobox());5});6exports.mul4x4 = function(a, b) {7 var c = new Array(4);8 for (var i = 0; i < 4; i++) {9 c[i] = new Array(4);10 for (var j = 0; j < 4; j++) {11 c[i][j] = 0;12 for (var k = 0; k < 4; k++) {13 c[i][j] += a[i][k] * b[k][j];14 }15 }16 }17 return c;18};19exports.infobox = function() {20 var self = this;21 var keys = Object.keys(self.data).sort();22 var obj = {};23 for (var i = 0; i < keys.length; i++) {24 var key = keys[i];25 var val = self.data[key];26 if (self.is_infobox(key)) {27 obj[key] = self.parse(val);28 }29 }30 return obj;31};32exports.parse = function(val) {33 var self = this;34 if (typeof val === 'string') {35 val = val.trim();36 if (val.match(/^\{\{Infobox/)) {37 val = self.parse_infobox(val);38 } else if (val.match(/^\{\{.*\}\}$/)) {39 val = self.parse_template(val);40 } else if (val.match(/^\[\[.*\]\]$/)) {41 val = self.parse_link(val);42 val = self.parse_url(val);43 } else if (val.match(/^<ref/)) {44 val = self.parse_ref(val);45 } else if (val.match(/^<br\s?\/?>/))

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt');2var mat = wpt.createMatrix();3var vec = wpt.createVector();4var vec2 = wpt.createVector();5var vec3 = wpt.createVector();6var vec4 = wpt.createVector();7var vec5 = wpt.createVector();8var vec6 = wpt.createVector();9var vec7 = wpt.createVector();10var vec8 = wpt.createVector();11var vec9 = wpt.createVector();12var vec10 = wpt.createVector();13var vec11 = wpt.createVector();14var vec12 = wpt.createVector();15var vec13 = wpt.createVector();16var vec14 = wpt.createVector();17var vec15 = wpt.createVector();18var vec16 = wpt.createVector();19var vec17 = wpt.createVector();20var vec18 = wpt.createVector();21var vec19 = wpt.createVector();22var vec20 = wpt.createVector();23var vec21 = wpt.createVector();24var vec22 = wpt.createVector();25var vec23 = wpt.createVector();26var vec24 = wpt.createVector();27var vec25 = wpt.createVector();28var vec26 = wpt.createVector();29var vec27 = wpt.createVector();30var vec28 = wpt.createVector();31var vec29 = wpt.createVector();32var vec30 = wpt.createVector();33var vec31 = wpt.createVector();34var vec32 = wpt.createVector();35var vec33 = wpt.createVector();36var vec34 = wpt.createVector();37var vec35 = wpt.createVector();38var vec36 = wpt.createVector();39var vec37 = wpt.createVector();40var vec38 = wpt.createVector();41var vec39 = wpt.createVector();42var vec40 = wpt.createVector();43var vec41 = wpt.createVector();44var vec42 = wpt.createVector();45var vec43 = wpt.createVector();46var vec44 = wpt.createVector();47var vec45 = wpt.createVector();48var vec46 = wpt.createVector();49var vec47 = wpt.createVector();50var vec48 = wpt.createVector();51var vec49 = wpt.createVector();52var vec50 = wpt.createVector();53var vec51 = wpt.createVector();54var vec52 = wpt.createVector();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful