-
Notifications
You must be signed in to change notification settings - Fork 0
/
DunnM_hw07_p3.c~
44 lines (29 loc) · 1.27 KB
/
DunnM_hw07_p3.c~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/****************************************************************************
Marina Dunn
PHYS 305, Fall 2016
Created: 4 October 2016
Last Modified: 5 October 2016
Purpose: Instead of a linear correspondence, the drag force now increases quadratically with velocity. We want to again find t, the time at which the falling body reaches the ground. This approximation gives us the most realistic model for a falling body with air resistance.
Usage:
to compile: $gcc DunnM_hw07_p3.c -o DunnM_hw07_p3.exe -lm
to run: $DunnM_hw07_p3.exe
***************************************************************************/
#include <stdio.h>
#include <math.h>
//For quadratic drag, dv_y(t)/dt = -g(1 + v(t)|v(t)|/(v_term^2))
double a_quad(double g, double v, double v_term){
double value;
value = -g*(1+(v*abs(v))/(v_term*v_term))
}
int main (){
double x, y, t, v, vy, vx, v_term = 1000;
double y0 = 10; //initial vertical position in m
double h = 0.0001; // step size (in sec)
double v_x0 = 30; //m/s //initial horizontal velocity
double v_y0 = 0; // m/s // initial vertical velocity
double g = 9.8; // m/s^2 //gravitational constant
double t_half, t_start = 0, t_end; // in sec
double y_new, y_half, x_half, y_end = 0;
double v_new, v_half, a_half, a;
y = y0;
v = v_y0;