close

Dessinez un iceberg, vous comprendrez comment ils flottent

Dessinez un iceberg, vous comprendrez comment ils flottent



SCIENCE – Nous avons tous en tête l’image suivante de ce que devrait être un iceberg: un cône de glace flottant avec son sommet émergé et la majorité de sa masse s’enfonçant verticalement dans l’océan. Sauf que cette image est erronée, révèle Megan Thompson-Munson, glaciologue à l’université du Colorado. Les icebergs de forme allongée ne flottent pas verticalement, mais horizontalement explique la chercheuse. Pour vous en convaincre, nous vous proposons ci-dessous de dessiner et de faire flotter votre propre iceberg grâce à l’Iceberger, un simulateur dévoilé ce 20 février par le docteur Joshua Tauberer qui est un développeur informatique spécialisé dans les projets d’informations citoyennes.Iceberger Dessinez à l’aide de votre souris votre propre iceberg et faites le flotter.Iceberger
$(function() {
// Make the canvas nicely sized.
var h = $(“#canvas”).width() * 9/16;
if (h > $(window).height() – 50) h = $(window).height() – 50;
$(“#canvas”).height(h);

// Set the canvas coordinate system to match page units.
$(“#canvas”).attr(“width”, $(“#canvas”).width());
$(“#canvas”).attr(“height”, $(“#canvas”).height());

// Get the water level.
var yZero = $(“#canvas”).height() / 3;
var ctx = document.getElementById(‘canvas’).getContext(“2d”);

// Draw backgound.
function draw_background() {
// Sky
ctx.beginPath();
ctx.fillStyle = “#bbddee”;
ctx.moveTo(0, 0);
ctx.lineTo(0, ctx.canvas.height);
ctx.lineTo(ctx.canvas.width, ctx.canvas.height);
ctx.lineTo(ctx.canvas.width, 0);
ctx.closePath();
ctx.fill();

// Horizon
ctx.beginPath();
ctx.lineWidth = 1;
ctx.strokeStyle = “yellow”;
ctx.moveTo(0, yZero);
ctx.lineTo(ctx.canvas.width, yZero);
ctx.closePath();
ctx.stroke();

// Sun
ctx.beginPath();
ctx.fillStyle = “#fefec4”;
ctx.arc(ctx.canvas.width – 50, 35, 20, 0, 2 * Math.PI);
ctx.fill();

// Water
draw_water();
}
function draw_water() {
// Water
ctx.beginPath();
ctx.fillStyle = “#2c7bb6”;
ctx.moveTo(0, yZero);
ctx.lineTo(0, ctx.canvas.height);
ctx.lineTo(ctx.canvas.width, ctx.canvas.height);
ctx.lineTo(ctx.canvas.width, yZero);
ctx.closePath();
ctx.fill();
}
draw_background();
draw_water();

// Hook up draw events.
var mousePressed = false;
var polygon = null;
var velocity = [];
function add_point(e) {
if (e.touches)
e = e.touches[0];

var rect = $(“#canvas”)[0].getBoundingClientRect();
var x = e.clientX – rect.left;
var y = e.clientY – rect.top;
polygon.push([x, y]);

// Draw lasso.
if (polygon.length >= 2) {
ctx.beginPath();
ctx.strokeStyle = “black”;
ctx.lineWidth = 3;
ctx.lineJoin = “round”;
ctx.moveTo(polygon[polygon.length-2][0], polygon[polygon.length-2][1]);
ctx.lineTo(polygon[polygon.length-1][0], polygon[polygon.length-1][1]);
ctx.closePath();
ctx.stroke();
}
};
$(‘#canvas’).on(‘mousedown touchstart’, function (e) {
// Reset canvas.
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
draw_background();
draw_water();

mousePressed = true;
polygon = [];
add_point(e);
});
$(‘#canvas’).on(‘mousemove touchmove’, function (e) {
if (mousePressed)
add_point(e);
});
$(‘#canvas’).on(‘mouseup touchend’, function (e) {
// Finish drawing – reset the polygon and inertia.
mousePressed = false;
if (polygon.length 0) // make first and last point the same
polygon.push(polygon[0]);
velocity = [0, 0, 0];

// People like to draw shapes with kinks, which results
// in part of the polygon being treated as negative area.
// turf.unkinkPolygon can be used to find the kinks and
// separate the polygon into multiple polygons at the
// kinks, but it’s a little fragile and hard to combine
// into a single unkinked polygon. We also want to avoid
// showing errors when there are just small degenerate
// kinds from messy drawing.
// (If turf.kinks(turf.polygon([polygon])).features.length
// is non-zero, there are kinks. We could show an error,
// but that’s not friendly.)
try {
// Remove duplicate vertices which breaks unkinkPolygon.
var found_vertices = { };
var polygon2 = [];
polygon.forEach(function(pt) {
var k = pt[0] + “|” + pt[1];
if (k in found_vertices) return;
found_vertices[k] = true;
polygon2.push(pt);
})
polygon = polygon2;
polygon.push(polygon[0]);

// Split polygon into parts separated at kinks.
var k = turf.polygon([polygon]);
k = turf.unkinkPolygon(k);
if (k.features.length > 1) {
// Take the part with the largest area.
k = k.features.map(function(kk) { return kk.geometry.coordinates[0]; })
var areas = k.map(polygonArea);
var maxArea = 0, maxAreaIndex = 0;
areas.forEach(function(area, i) {
if (area > maxArea) {
maxArea = area;
maxAreaIndex = i;
}
});
polygon = k[maxAreaIndex];
}
} catch (e) {
}
});

var tick_repeat = function() {
tick();
setTimeout(tick_repeat, 50);
}
tick_repeat();

function tick() {
if (!polygon || polygon.length = 4) ? centroid(polygon_submerged) : [0, 0];

// The vector between the two centroids determines a
// force that is applied. Gravity pulls down (+y because
// the canvas coordinates are upside-down) at the
// center of mass of the full iceberg and bouyancy
// pushes up (-y) at the center of mass of the submerged
// portion.
var specific_gravity = .85;
var fg = 1;
var submerged_ratio = polygonArea(polygon_submerged) / polygonArea(polygon);
var fb = submerged_ratio / specific_gravity;
var fy = fg – fb;

// In reality, the 3D distribution of mass is not uniform
// across the 2D projection of the iceberg that we are looking
// at. While we can assume that it’s close, when we chop off
// the top of the iceberg to find the submerged portion,
// the centroid of the submerged portion is likely to be closer
// to the total centroid than the centroid of the projection of
// the submerged part because what we chop off is always close
// to an edge and the edges have lower density than in the middle.
// Adjust the centroid location of the submerged part accordingly.
// When half-way submerged, move the centroid 20% closer to the
// full cenroid.
var r = (submerged_ratio $(window).height() – 50) h = $(window).height() – 50;
$(“#canvas”).height(h);

// Set the canvas coordinate system to match page units.
$(“#canvas”).attr(“width”, $(“#canvas”).width());
$(“#canvas”).attr(“height”, $(“#canvas”).height());

// Get the water level.
var yZero = $(“#canvas”).height() / 3;
var ctx = document.getElementById(‘canvas’).getContext(“2d”);

// Draw backgound.
function draw_background() {
// Sky
ctx.beginPath();
ctx.fillStyle = “#bbddee”;
ctx.moveTo(0, 0);
ctx.lineTo(0, ctx.canvas.height);
ctx.lineTo(ctx.canvas.width, ctx.canvas.height);
ctx.lineTo(ctx.canvas.width, 0);
ctx.closePath();
ctx.fill();

// Horizon
ctx.beginPath();
ctx.lineWidth = 1;
ctx.strokeStyle = “yellow”;
ctx.moveTo(0, yZero);
ctx.lineTo(ctx.canvas.width, yZero);
ctx.closePath();
ctx.stroke();

// Sun
ctx.beginPath();
ctx.fillStyle = “#fefec4”;
ctx.arc(ctx.canvas.width – 50, 35, 20, 0, 2 * Math.PI);
ctx.fill();

// Water
draw_water();
}
function draw_water() {
// Water
ctx.beginPath();
ctx.fillStyle = “#2c7bb6”;
ctx.moveTo(0, yZero);
ctx.lineTo(0, ctx.canvas.height);
ctx.lineTo(ctx.canvas.width, ctx.canvas.height);
ctx.lineTo(ctx.canvas.width, yZero);
ctx.closePath();
ctx.fill();
}
draw_background();
draw_water();

// Hook up draw events.
var mousePressed = false;
var polygon = null;
var velocity = [];
function add_point(e) {
if (e.touches)
e = e.touches[0];

var rect = $(“#canvas”)[0].getBoundingClientRect();
var x = e.clientX – rect.left;
var y = e.clientY – rect.top;
polygon.push([x, y]);

// Draw lasso.
if (polygon.length >= 2) {
ctx.beginPath();
ctx.strokeStyle = “black”;
ctx.lineWidth = 3;
ctx.lineJoin = “round”;
ctx.moveTo(polygon[polygon.length-2][0], polygon[polygon.length-2][1]);
ctx.lineTo(polygon[polygon.length-1][0], polygon[polygon.length-1][1]);
ctx.closePath();
ctx.stroke();
}
};
$(‘#canvas’).on(‘mousedown touchstart’, function (e) {
// Reset canvas.
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
draw_background();
draw_water();

mousePressed = true;
polygon = [];
add_point(e);
});
$(‘#canvas’).on(‘mousemove touchmove’, function (e) {
if (mousePressed)
add_point(e);
});
$(‘#canvas’).on(‘mouseup touchend’, function (e) {
// Finish drawing – reset the polygon and inertia.
mousePressed = false;
if (polygon.length 0) // make first and last point the same
polygon.push(polygon[0]);
velocity = [0, 0, 0];

// People like to draw shapes with kinks, which results
// in part of the polygon being treated as negative area.
// turf.unkinkPolygon can be used to find the kinks and
// separate the polygon into multiple polygons at the
// kinks, but it’s a little fragile and hard to combine
// into a single unkinked polygon. We also want to avoid
// showing errors when there are just small degenerate
// kinds from messy drawing.
// (If turf.kinks(turf.polygon([polygon])).features.length
// is non-zero, there are kinks. We could show an error,
// but that’s not friendly.)
try {
// Remove duplicate vertices which breaks unkinkPolygon.
var found_vertices = { };
var polygon2 = [];
polygon.forEach(function(pt) {
var k = pt[0] + “|” + pt[1];
if (k in found_vertices) return;
found_vertices[k] = true;
polygon2.push(pt);
})
polygon = polygon2;
polygon.push(polygon[0]);

// Split polygon into parts separated at kinks.
var k = turf.polygon([polygon]);
k = turf.unkinkPolygon(k);
if (k.features.length > 1) {
// Take the part with the largest area.
k = k.features.map(function(kk) { return kk.geometry.coordinates[0]; })
var areas = k.map(polygonArea);
var maxArea = 0, maxAreaIndex = 0;
areas.forEach(function(area, i) {
if (area > maxArea) {
maxArea = area;
maxAreaIndex = i;
}
});
polygon = k[maxAreaIndex];
}
} catch (e) {
}
});

var tick_repeat = function() {
tick();
setTimeout(tick_repeat, 50);
}
tick_repeat();

function tick() {
if (!polygon || polygon.length = 4) ? centroid(polygon_submerged) : [0, 0];

// The vector between the two centroids determines a
// force that is applied. Gravity pulls down (+y because
// the canvas coordinates are upside-down) at the
// center of mass of the full iceberg and bouyancy
// pushes up (-y) at the center of mass of the submerged
// portion.
var specific_gravity = .85;
var fg = 1;
var submerged_ratio = polygonArea(polygon_submerged) / polygonArea(polygon);
var fb = submerged_ratio / specific_gravity;
var fy = fg – fb;

// In reality, the 3D distribution of mass is not uniform
// across the 2D projection of the iceberg that we are looking
// at. While we can assume that it’s close, when we chop off
// the top of the iceberg to find the submerged portion,
// the centroid of the submerged portion is likely to be closer
// to the total centroid than the centroid of the projection of
// the submerged part because what we chop off is always close
// to an edge and the edges have lower density than in the middle.
// Adjust the centroid location of the submerged part accordingly.
// When half-way submerged, move the centroid 20% closer to the
// full cenroid.
var r = (submerged_ratio

Source link : https://www.huffingtonpost.fr/entry/dessine-moi-un-iceberg-et-regarde-comme-tu-te-trompes-sur-sa-flottabilite_fr_60336928c5b6cc8bbf3cc42b

Author : Quang Pham

Publish date : 2021-02-22 15:12:42

Copyright for syndicated content belongs to the linked Source.

Tags : Huffington Post

Dessinez un iceberg, vous comprendrez comment ils flottent
https://paschers.info   https://www.maillotdebain.co.com   https://vinspro.org   https://comptoirdubagage.biz   https://atelier-aquariophilie.com  
--
wotogold Été Animal Dragon Rouge Pyjamas Costumes de Cosplay Pour Adultes Unisex *  Tequila Sauza Blanco 70 cl *  Stephen Hendry: Seven-time world champion loses comeback match against Matthew Selt *  * Bic blister gomme galet souple a (blanc) *  A closer look at Olympic and Paralympic funding for the Paris 2024 cycle *  Rugby World Cup 2021 set to be postponed until 2022, World Rugby announces *  Mesothelioma Treatment Market Status and Strategic Outlook 2021 to 2028 *  Emma ® Acide aminé et Vitamine E pour Chevaux I Booster I Pâte orale pour Un apport Rapide en acides aminés I favorise… *  * MLB updates code of conduct pertaining to harassment, discrimination in wake of allegations *  MLB Network Ranks Michael Conforto No. 7 Right Fielder *  https://dagmar-coward-kuschke.com   https://saecanada.net   https://100000-articles.com   https://paris-restos.com   https://www.atelier-aquariophilie.com   https://www.nyumba-ya-mumbi.org/   https://www.respectology.info/   https://notre-dame-de-paris.org   https://casqueaudiosansfil.org   https://www.espace-livres.com/   https://hommes.meilleureschaussures.com   https://www.7a7.biz/   https://www.magasinjouet.net/   https://www.lecordonniermalchausse.com