Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Pendulum Calculator #1802

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Calculators/Pendulum-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# <p align="center">Pendulum Calculator</p>

## Description :-

The Pendulum Calculator is a web application that calculates various properties of a pendulum system based on the length of the pendulum (l), the gravitational acceleration (g), the amplitude (A), and the mass of the bob (m). The calculator computes the following properties:

- Period of the Pendulum (T)
- Frequency of the Pendulum (f)
- Angular Frequency (ω)
- Maximum Speed
- Maximum Acceleration
- Kinetic Energy at the Lowest Point
- Potential Energy at the Highest Point

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Features :-

- Calculate the period, frequency, angular frequency, maximum speed, maximum acceleration, kinetic energy, and potential energy of a pendulum system.
- User-friendly interface with input fields for length, gravitational acceleration, amplitude, and mass.
- Responsive design with a background image and enhanced styling.
- Clear and detailed display of calculated results.

## Screenshots :-


29 changes: 29 additions & 0 deletions Calculators/Pendulum-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@500&display=swap" rel="stylesheet">
<title>Pendulum Calculator</title>
</head>
<body>
<header class="main">
<h1 class="header">Pendulum Calculator</h1>
<div class="calculator-container">
<label for="length">Length of Pendulum (l) in meters:</label>
<input type="number" id="length" name="length" required>
<label for="gravity">Gravitational Acceleration (g) in m/s²:</label>
<input type="number" id="gravity" name="gravity" required>
<label for="amplitude">Amplitude (A) in meters:</label>
<input type="number" id="amplitude" name="amplitude" required>
<label for="mass">Mass of the Bob (m) in kg:</label>
<input type="number" id="mass" name="mass" required>
<button class="submit-button" onclick="calculatePendulum()">Calculate</button>
<div class="results" id="results"></div>
</div>
</header>
<script src="script.js"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions Calculators/Pendulum-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function calculatePendulum() {
const length = parseFloat(document.getElementById('length').value);
const gravity = parseFloat(document.getElementById('gravity').value);
const amplitude = parseFloat(document.getElementById('amplitude').value);
const mass = parseFloat(document.getElementById('mass').value);

if (isNaN(length) || isNaN(gravity) || isNaN(amplitude) || isNaN(mass)) {
alert("Please enter valid numbers in all fields.");
return;
}

const T = 2 * Math.PI * Math.sqrt(length / gravity);
const f = 1 / T;
const w = 2 * Math.PI * f;
const v_max = amplitude * w;
const a_max = amplitude * Math.pow(w, 2);
const KE = 0.5 * mass * Math.pow(v_max, 2);
const PE = mass * gravity * amplitude;

const results = document.getElementById('results');
results.innerHTML = `
<h2>Results:</h2>
<p>Period of the Pendulum (T): ${T.toFixed(2)} s</p>
<p>Frequency of the Pendulum (f): ${f.toFixed(2)} Hz</p>
<p>Angular Frequency (ω): ${w.toFixed(2)} rad/s</p>
<p>Maximum Speed (v_max): ${v_max.toFixed(2)} m/s</p>
<p>Maximum Acceleration (a_max): ${a_max.toFixed(2)} m/s²</p>
<p>Kinetic Energy at the Lowest Point (KE): ${KE.toFixed(2)} J</p>
<p>Potential Energy at the Highest Point (PE): ${PE.toFixed(2)} J</p>
`;
}
118 changes: 118 additions & 0 deletions Calculators/Pendulum-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
body {
font-family: 'Roboto', sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(to right, #1e3c72, #2a5298);
background-size: cover;
background-position: center;
background-repeat: no-repeat;
flex-direction: column;
min-height: 100vh;
}

.header {
font-size: 3em;
font-weight: bold;
background: linear-gradient(to right, #ff6b6b, #ff9f43);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
animation: fadeInScale 2s ease-in-out;
margin-bottom: 20px;
}

@keyframes fadeInScale {
0% {
opacity: 0;
transform: scale(0.8);
}
100% {
opacity: 1;
transform: scale(1);
}
}

.main {
text-align: center;
background: rgba(255, 255, 255, 0.95);
padding: 30px;
border-radius: 15px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
max-width: 400px;
width: 100%;
overflow: hidden;
}

.calculator-container {
background-color: rgba(255, 255, 255, 0.9);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
border-radius: 10px;
padding: 20px;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
overflow: auto;
}

label {
font-size: 1.2em;
color: #333;
margin-bottom: 10px;
}

input {
padding: 10px;
font-size: 1em;
border: 1px solid #ddd;
border-radius: 4px;
background-color: #f9f9f9;
margin-bottom: 15px;
width: 100%;
box-sizing: border-box;
}

input:focus {
border-color: #007bff;
outline: none;
}

.submit-button {
display: inline-block;
padding: 12px 24px;
background-color: #5d13d4;
color: white;
border: none;
border-radius: 25px;
cursor: pointer;
font-size: 1em;
transition: background-color 0.3s, transform 0.3s;
}

.submit-button:hover {
background-color: #45a049;
transform: scale(1.05);
}

.results {
margin-top: 20px;
text-align: left;
width: 100%;
}

.results h2 {
margin-bottom: 10px;
font-size: 1.5em;
color: #333;
}

.results p {
margin: 8px 0;
font-size: 1em;
color: #555;
}
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ <h3>Converts power values between AC and DC.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Pendulum Calculator</h2>
<h3>Calculates Properties of length, Gravitational and mass of bob.</h3>
<div class="card-footer">
<a href="./Calculators/Pendulum-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Pendulum-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>ASCII Value Calculator</h2>
Expand Down