|
|
| (Der Versionsvergleich bezieht 67 dazwischenliegende Versionen mit ein.) |
| Zeile 1: |
Zeile 1: |
| | <jsxgraph box="jxgbox" width="500" height="500"> | | <jsxgraph box="jxgbox" width="500" height="500"> |
| | | | |
| - | var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-5,5,5,-5], axis:true});
| + | var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-100,100,100,-100], axis:true}); |
| | | | |
| - | // Define the metal plate as a polygon
| + | var r=5; |
| - | var polygon = board.create('polygon', [[-4,-4], [-4,4], [4,4], [4,-4]], {fillcolor:'#ddd', hasInnerPoints:true});
| + | var p0; |
| | + | var p0=board.create('point', [0.0, 60.0],{size:5}); |
| | | | |
| - | // Define the initial temperature distribution as a function of x and y
| + | var c0=board.create('circle', [p0, r], {visible:false}); |
| - | function initialTemp(x,y) {
| + | |
| - | return 20 + 10*Math.sin(Math.PI*x/4)*Math.sin(Math.PI*y/4);
| + | |
| - | }
| + | |
| | | | |
| - | // Define the temperature function as a function of x and y and time
| |
| - | function temp(x,y,t) {
| |
| - | var k = 1;
| |
| - | var c = 1;
| |
| - | var rho = 1;
| |
| - | var alpha = k/(rho*c);
| |
| - | return initialTemp(x,y) + 10*Math.exp(-alpha*Math.PI*Math.PI*t/16)*Math.sin(Math.PI*x/4)*Math.sin(Math.PI*y/4);
| |
| - | }
| |
| | | | |
| - | // Create a grid of points to sample the temperature function
| + | for (let i = 0; i < 100; i++) { |
| - | var points = [];
| + | |
| - | for (var i=-4; i<=4; i+=0.5) {
| + | |
| - | for (var j=-4; j<=4; j+=0.5) {
| + | |
| - | points.push([i,j]);
| + | |
| - | }
| + | |
| - | }
| + | |
| | | | |
| - | // Plot the temperature distribution at time t=0
| + | var lx0=p0.X()-Math.sin((80-i*4)*Math.PI/180)*r; |
| - | var heatmap = board.create('heatmappolygon', [points, initialTemp], {colorscheme:'greyscale', minopacity:0.5});
| + | var ly0=p0.Y()-Math.cos((80-i*4)*Math.PI/180)*r; |
| | + | var lx1=p0.X()-Math.sin((20-i*4)*Math.PI/180)*r; |
| | + | var ly1=p0.Y()-Math.cos((20-i*4)*Math.PI/180)*r; |
| | + | var p0 = board.create('glider', [lx0, ly0,c0], { name: '1', withLabel: false, size:5, fillColor:"blue"}); |
| | + | var p1 = board.create('glider', [lx1, ly1,c0], { name: '1', withLabel: false, size:3}); |
| | | | |
| - | // Animate the temperature distribution over time
| + | var c0=board.create('circle', [p0, r], {visible:false}); |
| - | var time = 0;
| + | |
| - | var dt = 0.1;
| + | |
| - | var interval = setInterval(function() {
| + | |
| - | time += dt;
| + | |
| - | var values = [];
| + | |
| - | for (var i=0; i<points.length; i++) {
| + | |
| - | values.push(temp(points[i][0], points[i][1], time));
| + | |
| - | }
| + | |
| - | heatmap.updateData(values);
| + | |
| - | if (time >= 2) clearInterval(interval);
| + | |
| - | }, 100);
| + | |
| | | | |
| | + | } |
| | | | |
| - |
| |
| | </jsxgraph> | | </jsxgraph> |