Tides: Earth, Moon, and Gravitational Interaction

An educational tool to demonstrate the effect of the Moon's gravitational pull on Earth's tides for advanced high school students.

AI

Model: gpt-4-0314
Time: 1681263332 seconds
Prompt Tokens: 2351
Completion Tokens: 1463
Total Token Cost: 3814

Get This App On Your Website

1. Copy the code above with the iframe and link.
2. Paste the code into your website.
3. Resize the iframe to fit your website.

Javascript, HTML, CSS Code

                    <html>
<head>
<script type="text/javascript"> window.addEventListener('error', function(event) { var message = JSON.parse(JSON.stringify(event.message)); var source = event.filename; var lineno = event.lineno; var colno = event.colno; var error = event.error; window.parent.postMessage({ type: 'iframeError', details: { message: message, source: source, lineno: lineno, colno: colno, error: error ? error.stack : '' } }, '*'); }); window.addEventListener('unhandledrejection', function(event) { window.parent.postMessage({ type: 'iframePromiseRejection', details: { reason: event.reason } }, '*'); }); </script>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>Tides: Earth, Moon, and Gravitational Interaction</title>
<meta name="description" content="An educational tool to demonstrate the effect of the Moon's gravitational pull on Earth's tides for advanced high school students.">
<meta name="keywords" content="tides, Earth, Moon, gravitational interaction, high school, education">

<!-- Import Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@400;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inconsolata&display=swap" rel="stylesheet">

<script type="text/javascript">
// Built-In Functions for Apps
var localStoragePrefix = "ct-16812328183068";
var lastSave = 0;

function saveLocal(data) {
// ... Save to localstorage code ...
}

function loadLocal() {
// ... Load from localstorage code ...
}
</script>

<script type="text/javascript">
// App Javascript Goes Here
let canvas, ctx, earth, moon;
let earthRadius = 50, moonRadius = 15, distance = 250;
let angle = 0, earthX, earthY, moonX, moonY, tideHeight, tideAngle;
let canvasWidth = 800, canvasHeight = 400;
let earthRotation = 0;

function init() {
canvas = document.getElementById("tide-animation");
ctx = canvas.getContext("2d");
earthX = canvasWidth / 2;
earthY = canvasHeight / 2;
animateTides();
}

function drawEarth() {
ctx.save();
ctx.translate(earthX, earthY);
ctx.rotate(earthRotation);
ctx.beginPath();
ctx.arc(0, 0, earthRadius, 0, Math.PI * 2);
ctx.fillStyle = "#4CAF50";
ctx.fill();
ctx.closePath();
ctx.restore();
}

function drawMoon() {
ctx.beginPath();
ctx.arc(moonX, moonY, moonRadius, 0, Math.PI * 2);
ctx.fillStyle = "#F0E68C";
ctx.fill();
ctx.closePath();
}

function drawTides() {
ctx.save();
ctx.translate(earthX, earthY);
ctx.rotate(tideAngle);
ctx.beginPath();
ctx.arc(0, 0, earthRadius + tideHeight, -0.52, +0.52);
ctx.arc(0, 0, earthRadius + tideHeight, Math.PI - 0.52, Math.PI + 0.52);
ctx.fillStyle = "rgba(65, 105, 225, 0.5)";
ctx.fill();
ctx.closePath();
ctx.restore();
}

function drawDot() {
ctx.save();
ctx.translate(earthX, earthY);
ctx.rotate(earthRotation);
ctx.beginPath();
ctx.arc(earthRadius, 0, 2, 0, Math.PI * 2);
ctx.fillStyle = "black";
ctx.fill();
ctx.closePath();
ctx.restore();
}

function calculatePositions() {
moonX = earthX + distance * Math.cos(angle);
moonY = earthY - distance * Math.sin(angle);
angle += 0.01;
earthRotation += 0.02;

// Calculate tide height based on distance between Earth and Moon
tideHeight = 15 * (1 - Math.abs(distance - earthRadius - moonRadius) / 350);

// Calculate tide angle based on the position of the Moon
tideAngle = Math.atan2(earthY - moonY, earthX - moonX);
}

function animateTides() {
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
calculatePositions();
drawEarth();
drawMoon();
drawTides();
drawDot();
requestAnimationFrame(animateTides);
}
</script>

<style>
/* App CSS Goes Here */
body {
font-family: 'Roboto Slab', serif;
background: linear-gradient(45deg, #81D4FA, #4FC3F7);
color: #333;
}

#main-container {
text-align: center;
padding: 20px;
font-size: 1.1rem;
}

#tide-animation {
border: 2px solid #333;
border-radius: 5px;
margin-bottom: 20px;
}

h1 {
font-size: 2.2rem;
font-weight: bold;
margin-bottom: 20px;
}

code {
font-family: 'Inconsolata', monospace;
font-size: 1.1rem;
background-color: rgba(255, 255, 255, 0.7);
padding: 2px 5px;
border-radius: 3px;
}
</style>

<link rel="canonical" href="https://calculator.tools/prompt/299/">
<meta charset="utf-8">
</head>
<body onload="init()">
<div id="main-container" class="container">
<h1>Tidal Animation: Earth 🌍 and Moon 🌕</h1>
<canvas id="tide-animation" width="800" height="400"></canvas>
<p>
In this animation, the Earth 🌍 and Moon 🌕 are shown with their relative sizes and distances (not to scale). The Moon's gravitational pull causes the water on Earth's surface to bulge, creating tides on the side facing the Moon and the opposite side. This effect is demonstrated by the blue semi-transparent layer around the Earth.
</p>
<p>
The tides are created due to the gravitational interaction between the Earth and Moon. The Moon's gravity pulls on the Earth, causing the water on the Earth's surface to bulge towards the Moon. This bulge is the high tide. On the opposite side of the Earth, another high tide occurs due to the Earth being pulled towards the Moon, while the water on the far side remains behind.
</p>
<p>
The Earth spins on its axis, making it appear as if the tide is moving around the Earth. In reality, it is the Earth's rotation that causes the tides to change throughout the day.
</p>
<p>
This animation is intended as an educational tool for advanced high school students. It helps to visualize and understand the concept of tides and the gravitational interaction between the Earth and Moon.
</p>
</div>
<script type="text/javascript"> var localStoragePrefix = "ct-{{ cachebreaker }}"; var lastSave = 0; function saveLocal(data) { if (Date.now() - lastSave < 1000) { return; } let cookie = localStoragePrefix + "=" + JSON.stringify(data) + "; path=" + window.location.pathname + "'; SameSite=Strict"; cookie += "; expires=" + new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 1000).toUTCString(); document.cookie = cookie; lastSave = Date.now(); } function loadLocal() { var cookiePrefix = localStoragePrefix + "="; var cookieStart = document.cookie.indexOf(cookiePrefix); if (cookieStart > -1) { let cookieEnd = document.cookie.indexOf(";", cookieStart); if (cookieEnd == -1) { cookieEnd = document.cookie.length; } var cookieData = document.cookie.substring(cookieStart + cookiePrefix.length, cookieEnd); return JSON.parse(cookieData); } } </script>

<script type="text/javascript"> window.addEventListener('load', function() { var observer = new MutationObserver(function() { window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); observer.observe(document.body, {attributes: true, childList: true, subtree: true}); window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); </script>
</body>
</html>

FAQ

What is Calculator Tools?

Calculator Tools allows you to instantly create and generate any simple one page web app for free and immediately have it online to use and share. This means anything! Mini apps, calculators, trackers, tools, games, puzzles, screensavers... anything you can think of that the AI can handle.

The AI uses Javacript, HTML, and CSS programming to code your app up in moments. This currently uses GPT-4 the latest and most powerful version of the OpenAI GPT language model.

What Do You Mean Make An App?

Have you ever just wanted a simple app but didn't want to learn programming or pay someone to make it for you? Calculator Tools is the solution! Just type in your prompt and the AI will generate a simple app for you in seconds. You can then customize it to your liking and share it with your friends.

AI has become so powerful it is that simple these days.

Does This Use ChatGPT?

It uses GPT-4 which is the most powerful model for ChatGPT.

Calculator Tools does not remember things from prompt to prompt, each image is a unique image that does not reference any of the images or prompts previously supplied.