summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-09-30 16:26:17 -0400
committerSam Anthony <sam@samanthony.xyz>2024-09-30 16:26:17 -0400
commit875b78cfddaf1fbf2d9c34de6091f582596b33e7 (patch)
tree112831336bf71990b8a0140da6f4e2f216e3fb01
parent11baf122132e7e7dceb2f286c0bbd94735d37b36 (diff)
downloadballs-875b78cfddaf1fbf2d9c34de6091f582596b33e7.zip
mass function of area
-rw-r--r--balls.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/balls.c b/balls.c
index 1c8fb4c..1b17304 100644
--- a/balls.c
+++ b/balls.c
@@ -20,7 +20,7 @@ enum {
DEFAULT_NBALLS = 3,
VMAX = 3,
- MASS_FACTOR = 1,
+ MASS_FACTOR = 75,
G_PER_KG = 1000,
FPS = 60,
@@ -57,6 +57,7 @@ Point randptinrect(Rectangle r);
int randint(int lo, int hi);
uint maxelem(uint arr[], uint n);
double mass(uint radius);
+double area(double radius);
void ball(void *arg);
void broadcast(Channel *cs[], int n, void *v);
void frametick(void *arg);
@@ -279,7 +280,12 @@ maxelem(uint arr[], uint n) {
double
mass(uint radius) {
- return (double) radius / MASS_FACTOR / G_PER_KG;
+ return area(radius) / MASS_FACTOR / G_PER_KG;
+}
+
+double
+area(double radius) {
+ return M_PI * radius*radius;
}
void