Mail Archives: djgpp/1998/03/04/08:30:29
From: | "Jos A. Horsmeier" <jos AT and DOT nl>
|
Newsgroups: | comp.os.msdos.djgpp,comp.lang.c
|
Subject: | Re: trigonometry problem (math.h)
|
Date: | Wed, 04 Mar 1998 14:30:03 +0100
|
Organization: | AND Software B.V. Rotterdam
|
Message-ID: | <34FD575B.F11FCD3D@and.nl>
|
References: | <34FC314E DOT A9B3F9D6 AT usa DOT net>
|
NNTP-Posting-Host: | beach.and.nl
|
Mime-Version: | 1.0
|
Lines: | 32
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Jesse Meyer wrote:
> I am writing some code to determine the vertical velocity of a
> projectile.
> The physics equation is voy = x (units/second) * sin(angle)
> I want to design a program that will calculate this given the inital
> velocity (x) and the angle.
> I am using DJGPP v2.01 and RHIDE 1.4
> This is basically a programming question because I am a begginer and all
> the books I read don't go into using Trig with C.
If the 'sin' function is the problem, all you have to do is include
<math.h> at the top of your source file, add your code, and compile
the stuff. Don't forget to link in the math library (check your
manuals for the correct command line flags) and voila!
Here are some formulas:
- V(0) is the initial velocity
- Vv(0)= V(0)*sin(angle) is the vertical component
- Vv(t)= Vv(0)-g*t (g == gravity ~ 9.81 m/s^2)
And remember, whatever goes up comes down; here's some code:
int O,o,Oo=10*0x11; main(){for (O=!0<<!0<<!0<<!0,
O++; O--;o++)printf(O?"%*s%s":"%*s\n%s%*s\n%x%x%"
"x%xrghh %s\n",O?o++:o+!0,O?".":"\\,/",O?"\n\n\n"
"\n\n\n\n\n\n"+O: "",o,"|",Oo,Oo,Oo,Oo," /0\\");}
kind regards,
Jos aks jos AT and DOT nl
- Raw text -