Matrix multiplication: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
(17 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
< | <jsxgraph box="box1" width="400" height="300"> | ||
var b1 = JXG.JSXGraph.initBoard('box1', {boundingbox: [-7.5, 7.5, 12.5, -7.5], axis: true}); | |||
b1 = JXG.JSXGraph.initBoard('box1', { | |||
b1.suspendUpdate(); | b1.suspendUpdate(); | ||
var a = b1.create('slider',[[-5,-2],[5,-2],[-5,1,5]],{name:'a', snapWidth: 0.1}); | |||
var b = b1.create('slider',[[-5,-3],[5,-3],[-5,0,5]],{name:'b', snapWidth: 0.1}); | |||
var c = b1.create('slider',[[-5,-4],[5,-4],[-5,0,5]],{name:'c', snapWidth: 0.1}); | |||
b = b1. | var d = b1.create('slider',[[-5,-5],[5,-5],[-5,1,5]],{name:'d', snapWidth: 0.1}); | ||
c = b1. | |||
d = b1. | |||
v = b1. | var v = b1.create('point',[2,2],{size:3,name:'v'}); | ||
w = b1. | var w = b1.create('point',[-2,1],{size:3,name:'w'}); | ||
va = b1. | var va = b1.create('arrow',[[0,0],v]); | ||
wa = b1. | var wa = b1.create('arrow',[[0,0],w]); | ||
b1.unsuspendUpdate(); | b1.unsuspendUpdate(); | ||
</jsxgraph> | |||
b2 = JXG.JSXGraph.initBoard('box2', { | <jsxgraph box="box2" width="400" height="300"> | ||
var b2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-7.5, 7.5, 12.5, -7.5], axis: true}); | |||
b1.addChild(b2); | |||
b2.suspendUpdate(); | b2.suspendUpdate(); | ||
v2 = b2. | var v2 = b2.create('point',[ | ||
function() {return a. | function() {return a.Value()*v.X()+b.Value()*v.Y();}, | ||
function() {return c. | function() {return c.Value()*v.X()+d.Value()*v.Y();}],{face:'[]',size:2,name:"v'"}); | ||
w2 = b2. | var w2 = b2.create('point',[ | ||
function() {return a. | function() {return a.Value()*w.X()+b.Value()*w.Y();}, | ||
function() {return c. | function() {return c.Value()*w.X()+d.Value()*w.Y();}],{face:'[]',size:2,name:"w'"}); | ||
va2 = b2. | var va2 = b2.create('line',[[0,0],v2],{straightFirst:false, straightLast:false, lastArrow:true}); | ||
wa2 = b2. | var wa2 = b2.create('line',[[0,0],w2],{straightFirst:false, straightLast:false, lastArrow:true}); | ||
t = b2. | var t = b2.create('text',[-6,-2,function(){ return '|'+(a.Value()).toFixed(2)+' '+(b.Value()).toFixed(2)+'|'+'<br>'+'|'+(c.Value()).toFixed(2)+' '+(d.Value()).toFixed(2)+'|';}]); | ||
b2.unsuspendUpdate(); | b2.unsuspendUpdate(); | ||
</jsxgraph> | |||
=== References === | |||
* [http://en.wikipedia.org/wiki/Matrix_multiplication http://en.wikipedia.org/wiki/Matrix_multiplication] | |||
=== The underlying JavaScript code === | |||
<source lang="javascript"> | <source lang="javascript"> | ||
var b1 = JXG.JSXGraph.initBoard('box1', {boundingbox: [-7.5, 7.5, 12.5, -7.5], axis: true}); | |||
b1.suspendUpdate(); | |||
var a = b1.create('slider',[[-5,-2],[5,-2],[-5,1,5]],{name:'a', snapWidth: 0.1}); | |||
var b = b1.create('slider',[[-5,-3],[5,-3],[-5,0,5]],{name:'b', snapWidth: 0.1}); | |||
var c = b1.create('slider',[[-5,-4],[5,-4],[-5,0,5]],{name:'c', snapWidth: 0.1}); | |||
var d = b1.create('slider',[[-5,-5],[5,-5],[-5,1,5]],{name:'d', snapWidth: 0.1}); | |||
var v = b1.create('point',[2,2],{size:3,name:'v'}); | |||
var w = b1.create('point',[-2,1],{size:3,name:'w'}); | |||
var va = b1.create('line',[[0,0],v],{straightFirst:false, straightLast:false, lastArrow:true}); | |||
var wa = b1.create('line',[[0,0],w],{straightFirst:false, straightLast:false, lastArrow:true}); | |||
b1.unsuspendUpdate(); | |||
b2 = JXG.JSXGraph.initBoard('box2', { | var b2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-7.5, 7.5, 12.5, -7.5], axis: true}); | ||
b1.addChild(b2); | |||
b2.suspendUpdate(); | b2.suspendUpdate(); | ||
v2 = b2. | var v2 = b2.create('point',[ | ||
function() {return a. | function() {return a.Value()*v.X()+b.Value()*v.Y();}, | ||
function() {return c. | function() {return c.Value()*v.X()+d.Value()*v.Y();}],{face:'[]',size:2,name:"v'"}); | ||
w2 = b2. | var w2 = b2.create('point',[ | ||
function() {return a. | function() {return a.Value()*w.X()+b.Value()*w.Y();}, | ||
function() {return c. | function() {return c.Value()*w.X()+d.Value()*w.Y();}],{face:'[]',size:2,name:"w'"}); | ||
va2 = b2. | var va2 = b2.create('line',[[0,0],v2],{straightFirst:false, straightLast:false, lastArrow:true}); | ||
wa2 = b2. | var wa2 = b2.create('line',[[0,0],w2],{straightFirst:false, straightLast:false, lastArrow:true}); | ||
t = b2. | var t = b2.create('text',[-6,-2,function(){ return '|'+(a.Value()).toFixed(2)+' '+(b.Value()).toFixed(2)+'|'+'<br>'+'|'+(c.Value()).toFixed(2)+' '+(d.Value()).toFixed(2)+'|';}]); | ||
b2.unsuspendUpdate(); | b2.unsuspendUpdate(); | ||
Latest revision as of 13:50, 17 July 2023
References
The underlying JavaScript code
var b1 = JXG.JSXGraph.initBoard('box1', {boundingbox: [-7.5, 7.5, 12.5, -7.5], axis: true});
b1.suspendUpdate();
var a = b1.create('slider',[[-5,-2],[5,-2],[-5,1,5]],{name:'a', snapWidth: 0.1});
var b = b1.create('slider',[[-5,-3],[5,-3],[-5,0,5]],{name:'b', snapWidth: 0.1});
var c = b1.create('slider',[[-5,-4],[5,-4],[-5,0,5]],{name:'c', snapWidth: 0.1});
var d = b1.create('slider',[[-5,-5],[5,-5],[-5,1,5]],{name:'d', snapWidth: 0.1});
var v = b1.create('point',[2,2],{size:3,name:'v'});
var w = b1.create('point',[-2,1],{size:3,name:'w'});
var va = b1.create('line',[[0,0],v],{straightFirst:false, straightLast:false, lastArrow:true});
var wa = b1.create('line',[[0,0],w],{straightFirst:false, straightLast:false, lastArrow:true});
b1.unsuspendUpdate();
var b2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-7.5, 7.5, 12.5, -7.5], axis: true});
b1.addChild(b2);
b2.suspendUpdate();
var v2 = b2.create('point',[
function() {return a.Value()*v.X()+b.Value()*v.Y();},
function() {return c.Value()*v.X()+d.Value()*v.Y();}],{face:'[]',size:2,name:"v'"});
var w2 = b2.create('point',[
function() {return a.Value()*w.X()+b.Value()*w.Y();},
function() {return c.Value()*w.X()+d.Value()*w.Y();}],{face:'[]',size:2,name:"w'"});
var va2 = b2.create('line',[[0,0],v2],{straightFirst:false, straightLast:false, lastArrow:true});
var wa2 = b2.create('line',[[0,0],w2],{straightFirst:false, straightLast:false, lastArrow:true});
var t = b2.create('text',[-6,-2,function(){ return '|'+(a.Value()).toFixed(2)+' '+(b.Value()).toFixed(2)+'|'+'<br>'+'|'+(c.Value()).toFixed(2)+' '+(d.Value()).toFixed(2)+'|';}]);
b2.unsuspendUpdate();