Skip to content

Commit

Permalink
looks (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
yhattav authored Nov 26, 2024
1 parent e2111c1 commit 36c0f79
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
11 changes: 2 additions & 9 deletions src/components/ParticleRenderer/ParticleRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,12 @@ export const ParticleRenderer: React.FC<ParticleRenderParams> = ({
velocity.x,
velocity.y,
"#4CAF50",
40
2
)}

{/* Force/Acceleration vector */}
{showForceArrows &&
drawArrow(
position.x,
position.y,
force.fx,
force.fy,
"#FF4081",
200
)}
drawArrow(position.x, position.y, force.fx, force.fy, "#FF4081", 2)}
</svg>
)}

Expand Down
6 changes: 3 additions & 3 deletions src/constants/physics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ interface BooleanSettingMetadata {
type SettingMetadata = SliderSettingMetadata | BooleanSettingMetadata;

export const PHYSICS_CONFIG = {
NEW_PARTICLE_MASS: 0.01,
NEW_PARTICLE_MASS: 0.1,
NEW_PARTICLE_ELASTICITY: 0.8,
FRICTION: 0.999,
FRICTION: 1,
DELTA_TIME: 1 / 60,
POINTER_MASS: 250000,
POINTER_MASS: 500000,
SHOW_VELOCITY_ARROWS: true,
SHOW_FORCE_ARROWS: true,
CONSTANT_FORCE_X: 0,
Expand Down
13 changes: 6 additions & 7 deletions src/utils/physics/physicsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ export const calculateGravityMagnitude = (
distance: number,
mass: number,
G = 0.1,
minDistance = 30,
maxForce = 2
minDistance = 10
//maxForce = Infinity
): number => {
const force = Math.min(
(G * mass) / Math.max(distance * distance, minDistance * minDistance),
maxForce
);
const force =
(G * mass) / Math.max(distance * distance, minDistance * minDistance);

return force;
};

Expand All @@ -54,7 +53,7 @@ export const calculateGravitationalForce = (
): Force => {
if (!isFinite(x1) || !isFinite(y1) || !isFinite(x2) || !isFinite(y2)) {
return { fx: 0, fy: 0 };
}
} // TODO: see if we can check the isFinite on x1+y1+x2+y2, is it faster?

const p1: Point2D = { x: x1, y: y1 };
const p2: Point2D = { x: x2, y: y2 };
Expand Down

0 comments on commit 36c0f79

Please sign in to comment.