AARIFSHABIR commited on
Commit
0e62845
·
verified ·
1 Parent(s): 3a6c368

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +6 -4
  2. index.html +371 -19
  3. prompts.txt +1 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Projectile
3
- emoji: 📉
4
  colorFrom: purple
5
- colorTo: blue
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: projectile
3
+ emoji: 🐳
4
  colorFrom: purple
5
+ colorTo: green
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,371 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Projectile Motion Learning App</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .projectile-path {
11
+ height: 250px;
12
+ position: relative;
13
+ overflow: hidden;
14
+ }
15
+ .projectile {
16
+ width: 20px;
17
+ height: 20px;
18
+ background-color: #3B82F6;
19
+ border-radius: 50%;
20
+ position: absolute;
21
+ bottom: 0;
22
+ left: 5%;
23
+ transition: all 0.1s linear;
24
+ }
25
+ .ground {
26
+ position: absolute;
27
+ bottom: 0;
28
+ width: 100%;
29
+ height: 2px;
30
+ background-color: #555;
31
+ }
32
+ #animationCanvas {
33
+ width: 100%;
34
+ height: 100%;
35
+ }
36
+ </style>
37
+ </head>
38
+ <body class="bg-gray-100 min-h-screen">
39
+ <div class="container mx-auto px-4 py-8">
40
+ <header class="text-center mb-12">
41
+ <h1 class="text-4xl font-bold text-blue-600 mb-2">Projectile Motion Master</h1>
42
+ <p class="text-gray-600 text-lg">Learn, calculate, and visualize projectile motion problems</p>
43
+ </header>
44
+
45
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
46
+ <!-- Theory Section -->
47
+ <div class="bg-white rounded-lg shadow-lg p-6">
48
+ <h2 class="text-2xl font-semibold text-blue-600 mb-4 border-b pb-2">Theory</h2>
49
+ <div class="space-y-4">
50
+ <div class="bg-blue-50 p-4 rounded">
51
+ <h3 class="font-medium text-blue-800">What is Projectile Motion?</h3>
52
+ <p class="text-gray-700 mt-2">Projectile motion is the motion of an object thrown or projected into the air, subject only to acceleration as a result of gravity.</p>
53
+ </div>
54
+
55
+ <div class="bg-blue-50 p-4 rounded">
56
+ <h3 class="font-medium text-blue-800">Key Equations</h3>
57
+ <ul class="list-disc pl-5 mt-2 space-y-1 text-gray-700">
58
+ <li><strong>Horizontal motion:</strong> x = v₀cosθ × t</li>
59
+ <li><strong>Vertical motion:</strong> y = v₀sinθ × t - ½gt²</li>
60
+ <li><strong>Time of flight:</strong> T = (2v₀sinθ)/g</li>
61
+ <li><strong>Maximum height:</strong> H = (v₀²sin²θ)/2g</li>
62
+ <li><strong>Range:</strong> R = (v₀²sin2θ)/g</li>
63
+ </ul>
64
+ </div>
65
+
66
+ <div class="bg-blue-50 p-4 rounded">
67
+ <h3 class="font-medium text-blue-800">Parameters</h3>
68
+ <ul class="list-disc pl-5 mt-2 space-y-1 text-gray-700">
69
+ <li><strong>v₀</strong> = initial velocity (m/s)</li>
70
+ <li><strong>θ</strong> = projection angle (degrees)</li>
71
+ <li><strong>g</strong> = acceleration due to gravity (9.8 m/s²)</li>
72
+ <li><strong>t</strong> = time (s)</li>
73
+ </ul>
74
+ </div>
75
+ </div>
76
+ </div>
77
+
78
+ <!-- Calculator Section -->
79
+ <div class="bg-white rounded-lg shadow-lg p-6">
80
+ <h2 class="text-2xl font-semibold text-blue-600 mb-4 border-b pb-2">Problem Solver</h2>
81
+ <div class="space-y-4">
82
+ <div>
83
+ <label for="velocity" class="block text-sm font-medium text-gray-700">Initial Velocity (m/s)</label>
84
+ <input type="number" id="velocity" min="0" value="20" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500">
85
+ </div>
86
+
87
+ <div>
88
+ <label for="angle" class="block text-sm font-medium text-gray-700">Projection Angle (degrees)</label>
89
+ <input type="number" id="angle" min="0" max="90" value="45" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500">
90
+ </div>
91
+
92
+ <div>
93
+ <label for="height" class="block text-sm font-medium text-gray-700">Initial Height (m)</label>
94
+ <input type="number" id="height" min="0" value="0" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500">
95
+ </div>
96
+
97
+ <button onclick="calculateProjectile()" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-md transition duration-300">
98
+ Calculate
99
+ </button>
100
+
101
+ <div id="results" class="hidden space-y-2 mt-4 border-t pt-4">
102
+ <h3 class="font-semibold text-gray-800">Results:</h3>
103
+ <p id="timeOfFlight" class="text-gray-700"></p>
104
+ <p id="maxHeight" class="text-gray-700"></p>
105
+ <p id="range" class="text-gray-700"></p>
106
+ <div class="pt-4">
107
+ <button onclick="shareResults()" class="w-full flex items-center justify-center bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded-md transition duration-300">
108
+ <i class="fab fa-whatsapp mr-2"></i> Share on WhatsApp
109
+ </button>
110
+ </div>
111
+ </div>
112
+ </div>
113
+ </div>
114
+
115
+ <!-- Visualization Section -->
116
+ <div class="bg-white rounded-lg shadow-lg p-6">
117
+ <h2 class="text-2xl font-semibold text-blue-600 mb-4 border-b pb-2">Visualization</h2>
118
+ <div class="projectile-path bg-gray-50 rounded-md mb-4" id="projectileContainer">
119
+ <div class="ground"></div>
120
+ <div class="projectile" id="projectile"></div>
121
+ </div>
122
+ <div class="flex justify-center">
123
+ <button onclick="animateProjectile()" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-8 rounded-md transition duration-300">
124
+ Animate
125
+ </button>
126
+ </div>
127
+ </div>
128
+ </div>
129
+
130
+ <!-- Practice Problems Section -->
131
+ <div class="mt-16 bg-white rounded-lg shadow-lg p-6">
132
+ <h2 class="text-2xl font-semibold text-blue-600 mb-4 border-b pb-2">Practice Problems</h2>
133
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
134
+ <div class="bg-gray-50 p-4 rounded-lg border border-gray-200">
135
+ <h3 class="font-medium text-blue-700">Problem 1</h3>
136
+ <p class="text-gray-700 mt-2">A ball is thrown with an initial velocity of 15 m/s at an angle of 30° to the horizontal. Calculate the maximum height reached and the horizontal distance traveled.</p>
137
+ <button onclick="loadSolution(1)" class="mt-3 text-blue-600 hover:text-blue-800 text-sm font-medium">Show Solution</button>
138
+ <div id="solution1" class="hidden mt-3 bg-blue-50 p-3 rounded text-sm text-gray-700"></div>
139
+ </div>
140
+
141
+ <div class="bg-gray-50 p-4 rounded-lg border border-gray-200">
142
+ <h3 class="font-medium text-blue-700">Problem 2</h3>
143
+ <p class="text-gray-700 mt-2">A stone is thrown from a cliff 20 meters high with a velocity of 25 m/s at 15° above the horizontal. How long does it take to hit the ground?</p>
144
+ <button onclick="loadSolution(2)" class="mt-3 text-blue-600 hover:text-blue-800 text-sm font-medium">Show Solution</button>
145
+ <div id="solution2" class="hidden mt-3 bg-blue-50 p-3 rounded text-sm text-gray-700"></div>
146
+ </div>
147
+
148
+ <div class="bg-gray-50 p-4 rounded-lg border border-gray-200">
149
+ <h3 class="font-medium text-blue-700">Problem 3</h3>
150
+ <p class="text-gray-700 mt-2">A projectile is launched at 60° with the horizontal and lands 100 meters away. What was the initial velocity?</p>
151
+ <button onclick="loadSolution(3)" class="mt-3 text-blue-600 hover:text-blue-800 text-sm font-medium">Show Solution</button>
152
+ <div id="solution3" class="hidden mt-3 bg-blue-50 p-3 rounded text-sm text-gray-700"></div>
153
+ </div>
154
+
155
+ <div class="bg-gray-50 p-4 rounded-lg border border-gray-200">
156
+ <h3 class="font-medium text-blue-700">Problem 4</h3>
157
+ <p class="text-gray-700 mt-2">At what angle should you throw a ball to achieve the maximum range? Prove mathematically.</p>
158
+ <button onclick="loadSolution(4)" class="mt-3 text-blue-600 hover:text-blue-800 text-sm font-medium">Show Solution</button>
159
+ <div id="solution4" class="hidden mt-3 bg-blue-50 p-3 rounded text-sm text-gray-700"></div>
160
+ </div>
161
+ </div>
162
+ </div>
163
+ </div>
164
+
165
+ <script>
166
+ // Constants
167
+ const g = 9.8; // acceleration due to gravity in m/s²
168
+ let animationId;
169
+
170
+ // Calculate projectile motion parameters
171
+ function calculateProjectile() {
172
+ const v0 = parseFloat(document.getElementById('velocity').value);
173
+ const angle = parseFloat(document.getElementById('angle').value);
174
+ const h0 = parseFloat(document.getElementById('height').value);
175
+
176
+ if (isNaN(v0) || isNaN(angle) || isNaN(h0) || v0 <= 0 || angle < 0 || angle > 90 || h0 < 0) {
177
+ alert('Please enter valid positive values.\nAngle must be between 0 and 90 degrees.');
178
+ return;
179
+ }
180
+
181
+ const angleRad = angle * Math.PI / 180;
182
+ const v0x = v0 * Math.cos(angleRad);
183
+ const v0y = v0 * Math.sin(angleRad);
184
+
185
+ // Calculate time of flight (quadratic equation)
186
+ const a = -g / 2;
187
+ const b = v0y;
188
+ const c = h0;
189
+
190
+ // Quadratic formula (take the positive root)
191
+ const timeOfFlight = (-b - Math.sqrt(b*b - 4*a*c)) / (2*a);
192
+
193
+ // Maximum height
194
+ const maxHeight = h0 + (v0y * v0y) / (2 * g);
195
+
196
+ // Horizontal range
197
+ const range = v0x * timeOfFlight;
198
+
199
+ // Display results
200
+ document.getElementById('timeOfFlight').textContent = `Time of flight: ${timeOfFlight.toFixed(2)} seconds`;
201
+ document.getElementById('maxHeight').textContent = `Maximum height: ${maxHeight.toFixed(2)} meters`;
202
+ document.getElementById('range').textContent = `Horizontal range: ${range.toFixed(2)} meters`;
203
+ document.getElementById('results').classList.remove('hidden');
204
+
205
+ // Store results for sharing
206
+ sessionStorage.setItem('projectileResults', JSON.stringify({
207
+ velocity: v0,
208
+ angle: angle,
209
+ initialHeight: h0,
210
+ timeOfFlight: timeOfFlight.toFixed(2),
211
+ maxHeight: maxHeight.toFixed(2),
212
+ range: range.toFixed(2)
213
+ }));
214
+ }
215
+
216
+ // Animate projectile motion
217
+ function animateProjectile() {
218
+ const v0 = parseFloat(document.getElementById('velocity').value);
219
+ const angle = parseFloat(document.getElementById('angle').value);
220
+ const h0 = parseFloat(document.getElementById('height').value);
221
+
222
+ if (isNaN(v0) || isNaN(angle) || isNaN(h0) || v0 <= 0 || angle < 0 || angle > 90 || h0 < 0) {
223
+ alert('Please enter valid positive values first by clicking Calculate.\nAngle must be between 0 and 90 degrees.');
224
+ return;
225
+ }
226
+
227
+ const projectile = document.getElementById('projectile');
228
+ const container = document.getElementById('projectileContainer');
229
+ const containerWidth = container.clientWidth;
230
+ const containerHeight = container.clientHeight;
231
+
232
+ const angleRad = angle * Math.PI / 180;
233
+ const v0x = v0 * Math.cos(angleRad);
234
+ const v0y = v0 * Math.sin(angleRad);
235
+
236
+ // Calculate time of flight (same as in calculateProjectile)
237
+ const a = -g / 2;
238
+ const b = v0y;
239
+ const c = h0;
240
+ const timeOfFlight = (-b - Math.sqrt(b*b - 4*a*c)) / (2*a);
241
+
242
+ // Clear previous animation if any
243
+ if (animationId) {
244
+ cancelAnimationFrame(animationId);
245
+ }
246
+
247
+ // Scale factor to fit animation in container
248
+ const maxRange = v0x * timeOfFlight;
249
+ const maxHeight = h0 + (v0y * v0y) / (2 * g);
250
+ const xScale = (containerWidth * 0.8) / maxRange;
251
+ const yScale = (containerHeight * 0.8) / Math.max(maxHeight, h0);
252
+
253
+ let t = 0;
254
+ const dt = timeOfFlight / 100; // small time increments
255
+
256
+ function frame() {
257
+ if (t <= timeOfFlight) {
258
+ const x = v0x * t;
259
+ const y = h0 + v0y * t - 0.5 * g * t * t;
260
+
261
+ // Scale and position projectile (flip y-coordinate because CSS y increases downward)
262
+ projectile.style.left = `${5 + x * xScale}px`;
263
+ projectile.style.bottom = `${y * yScale}px`;
264
+
265
+ t += dt;
266
+ animationId = requestAnimationFrame(frame);
267
+ } else {
268
+ // Animation complete
269
+ projectile.style.left = '5%';
270
+ projectile.style.bottom = '0%';
271
+ }
272
+ }
273
+
274
+ // Start animation
275
+ frame();
276
+ }
277
+
278
+ // Share results on WhatsApp
279
+ function shareResults() {
280
+ const storedResults = sessionStorage.getItem('projectileResults');
281
+ if (!storedResults) {
282
+ alert('Please calculate results first.');
283
+ return;
284
+ }
285
+
286
+ const results = JSON.parse(storedResults);
287
+ const message = `Check out my projectile motion calculations!%0A%0AInitial Velocity: ${results.velocity} m/s%0AProjection Angle: ${results.angle}°%0AInitial Height: ${results.initialHeight} m%0A%0ATime of Flight: ${results.timeOfFlight} s%0AMaximum Height: ${results.maxHeight} m%0ARange: ${results.range} m%0A%0ACalculated using Projectile Motion Master app.`;
288
+
289
+ const url = `https://wa.me/?text=${message}`;
290
+ window.open(url, '_blank');
291
+ }
292
+
293
+ // Load practice problem solutions
294
+ function loadSolution(problemNum) {
295
+ const solutionDiv = document.getElementById(`solution${problemNum}`);
296
+
297
+ if (solutionDiv.classList.contains('hidden')) {
298
+ let solutionText = '';
299
+
300
+ switch(problemNum) {
301
+ case 1:
302
+ solutionText = `
303
+ <p class="font-medium">Given:</p>
304
+ <p>v₀ = 15 m/s, θ = 30°, g = 9.8 m/s²</p>
305
+
306
+ <p class="font-medium mt-2">1. Maximum height:</p>
307
+ <p>H = (v₀²sin²θ)/2g</p>
308
+ <p>H = (15² × sin²30°)/19.6</p>
309
+ <p>H = (225 × 0.25)/19.6 ≈ 2.87 m</p>
310
+
311
+ <p class="font-medium mt-2">2. Horizontal range:</p>
312
+ <p>R = (v₀²sin2θ)/g</p>
313
+ <p>R = (15² × sin60°)/9.8</p>
314
+ <p>R = (225 × 0.866)/9.8 ≈ 19.88 m</p>
315
+ `;
316
+ break;
317
+ case 2:
318
+ solutionText = `
319
+ <p class="font-medium">Given:</p>
320
+ <p>v₀ = 25 m/s, θ = 15°, h₀ = 20 m, g = 9.8 m/s²</p>
321
+
322
+ <p class="font-medium mt-2">Vertical motion equation:</p>
323
+ <p>y = h₀ + v₀sinθ × t - ½gt²</p>
324
+ <p>At landing, y = 0:</p>
325
+ <p>0 = 20 + 25sin15° × t - 4.9t²</p>
326
+ <p>0 = 20 + 6.47t - 4.9t²</p>
327
+
328
+ <p class="mt-2">Solve quadratic equation:</p>
329
+ <p>t = [-6.47 ± √(6.47² + 4×4.9×20)] / (-9.8)</p>
330
+ <p>t = [-6.47 ± 20.46] / -9.8</p>
331
+ <p>Positive solution: t ≈ 2.75 seconds</p>
332
+ `;
333
+ break;
334
+ case 3:
335
+ solutionText = `
336
+ <p class="font-medium">Given:</p>
337
+ <p>θ = 60°, R = 100 m, g = 9.8 m/s²</p>
338
+
339
+ <p class="font-medium mt-2">Range equation:</p>
340
+ <p>R = (v₀²sin2θ)/g</p>
341
+ <p>100 = (v₀² × sin120°)/9.8</p>
342
+ <p>100 = (v₀² × 0.866)/9.8</p>
343
+ <p>v₀² = (100 × 9.8)/0.866 ≈ 1131.6</p>
344
+ <p>v₀ ≈ √1131.6 ≈ 33.64 m/s</p>
345
+ `;
346
+ break;
347
+ case 4:
348
+ solutionText = `
349
+ <p class="font-medium">Maximum range occurs at 45°</p>
350
+
351
+ <p class="font-medium mt-2">Proof:</p>
352
+ <p>Range equation: R = (v₀²sin2θ)/g</p>
353
+ <p>To maximize R, maximize sin2θ</p>
354
+ <p>Maximum value of sin2θ is 1 when 2θ = 90°</p>
355
+ <p>Therefore θ = 45° gives maximum range</p>
356
+
357
+ <p class="mt-2">At 45°:</p>
358
+ <p>R<sub>max</sub> = v₀²/g</p>
359
+ `;
360
+ break;
361
+ }
362
+
363
+ solutionDiv.innerHTML = solutionText;
364
+ solutionDiv.classList.remove('hidden');
365
+ } else {
366
+ solutionDiv.classList.add('hidden');
367
+ }
368
+ }
369
+ </script>
370
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=AARIFSHABIR/projectile" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
371
+ </html>
prompts.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Make app for learning and solving numericals based on projectile motion and how to share it on whatsapp