Skip to content
Merged
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
8 changes: 8 additions & 0 deletions app/(core)/data/chapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ const chapters = [
tags: [TAGS.MEDIUM, TAGS.DYNAMICS, TAGS.FORCES, TAGS.FRICTION],
icon: "/icons/inclined.png",
},
{
id: 9,
name: "Circular Motion",
desc: "Explore uniform circular motion in real time. Visualize velocity and centripetal acceleration vectors while adjusting radius and speed interactively.",
link: "/simulations/CircularMotion",
tags: [TAGS.MEDIUM, TAGS.DYNAMICS, TAGS.KINEMATICS, TAGS.VECTORS],
icon: "/icons/circular.png",
},
{
id: 0,
name: "Browser Performance & Stress Test",
Expand Down
104 changes: 104 additions & 0 deletions app/(core)/data/configs/CircularMotion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { physicsYToScreenY } from "../../constants/Utils.js";

Check warning on line 1 in app/(core)/data/configs/CircularMotion.js

View workflow job for this annotation

GitHub Actions / check

'physicsYToScreenY' is defined but never used

export const INITIAL_INPUTS = {
radius: 1,
speed: 2,
mass: 1,
size: 0.3,
color: "#7f7f7f",
trailEnabled: true,
}; //radius, tangential speed, mass, size, color, trailEnabled defaults

export const INPUT_FIELDS = [
{
type: "number",
name: "radius",
label: "r - Radius (m)",
min: 0.1,
step: 0.1,
},
{
type: "number",
name: "speed",
label: "v - Tangential Speed (m/s)",
min: 0,
step: 0.1,
},
{
type: "number",
name: "mass",
label: "m - Mass (kg)",
min: 0.1,
step: 0.1,
},
{
type: "number",
name: "size",
label: "d - Ball diameter (m)",
min: 0,
step: 0.1,
},
{ name: "trailEnabled", label: "Enable trail", type: "checkbox" },
{
type: "color",
name: "color",
label: "Ball Color",
},
];

export const FORCES = [
{
key: "centripetal",
color: "blue",
computeFn: ({ pos, center, mass, speed, radius }) => {

Check warning on line 53 in app/(core)/data/configs/CircularMotion.js

View workflow job for this annotation

GitHub Actions / check

'mass' is defined but never used
if (!pos || !center) return null;

const dx = center.x - pos.x;
const dy = center.y - pos.y;

const dist = Math.sqrt(dx * dx + dy * dy);
if (dist === 0) return null;

const dirX = dx / dist;
const dirY = dy / dist;

// a = v^2 / r
const acc = (speed * speed) / radius;

return {
x: dirX * acc,
y: dirY * acc,
};
},
},
{
key: "velocity",
color: "red",
computeFn: ({ vel }) => {
if (!vel) return null;
return { x: vel.x, y: vel.y };
},
},
];

export const SimInfoMapper = (state) => {
const { position, velocity, radius, speed } = state;

const acc = radius > 0 ? (speed * speed) / radius : 0;
const omega = radius > 0 ? speed / radius : 0;
const period = omega > 0 ? (2 * Math.PI) / omega : 0;

return {
"s(x, y) (position)": position
? `(${position.x.toFixed(2)}, ${position.y.toFixed(2)}) m`
: "-",

"v (speed)": velocity ? velocity.mag().toFixed(2) + " m/s" : "-",

"aβ‚™ (centripetal acc)": acc.toFixed(3) + " m/sΒ²",

"Ο‰ (angular velocity)": omega.toFixed(3) + " rad/s",

"T (period)": period.toFixed(3) + " s",
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@typescript-eslint/parser": "^8.53.0",
"axios": "^1.13.2",
"dotenv": "^17.2.3",
"eslint": "^10.0.2",
"eslint": "^9.39.4",
"eslint-config-next": "16.1.6",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24",
Expand Down
Binary file added public/icons/circular.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading