2. Determine Trajectory Information by Simple Numerical Integration Background A
ID: 3586626 • Letter: 2
Question
2. Determine Trajectory Information by Simple Numerical Integration Background A ball thrown or shot from the ground at an initial speed and at a given angle above horizontal will travel a certain distance, while it's vertical position first increases and then decreases until it hits the ground. For higher velocities, the drag (wind resistance) on the ball can be a significant factor Simple trigonometry shows that, for an overall initial speed So and angle , the initial x and y components of velocity will be x(0) S cos , and y(o) So sin o. Further, basic fluid mechanics says that the drag force on a sphere is given by Fe·½ A v/where C is the coefficient of drag (about 0.47 for a sphere) is the density of the fluid (1.225 kg/m) for air at sea level) A is the frontal area of the sphere ( v is the velocity Completing a free-body diagram of the ball and doing a little algebra, we can determine the acceleration in the x and y directions to be where m is the mass of the ball and g is the acceleration due to gravity (about 9.81 m/s). Project Write a program called trajectory. f95 that asks the user for speed So and angle of a launched projectile, which you can assume to be a 1 ball with a 0.1 m diameter. Use that info to calculate the trajectory travelled before it hits the ground. Use simple numerical integration to solve the system. For our purposes, that means Set initial values at time t = O. Assume that the ball starts at xo = 0 and y-0. The x and y components of velocity are given above. a. b. Start a loop that will run until the ball hits the ground. C. Update the time so that t = t + d. Call functions from a module that return the x and y components of acceleration, x"(t) and yIt). (More on this below.) "Integrate" to find the values of velocity and position at the next time step. In other words e. x(t+at)x(t) Atx(t) and x(t+4t)t)tx(t) And similarly for the y-direction Check whether the ball has fallen back to the ground ly s 0) and repeat if it has not. Terminate the loop if it has. f. A smaller At will result in more accurate results. You can experiment with different values for At, but test with 0.01 sec.Explanation / Answer
FUNCTION: Sets and returns switch char-
;; acter and device availability.
;;
;;
;;CALL:
;;
;; ret= _charop(al,dl)
;; int ret; DL return value,
;; int al; charoper function
;; int dl; charoper data
;;
;;RETURN:
;; See the DOS docs for details.
;;_charop(0,0) returns the ASCII switch char,
;;_charop(1,'-') sets the switch to -,
;;_charop(2,0) returns device availability,
;;_charop(3,i) sets device availability.
;;
;;
;;DESCRIPTION:
;;
;;EXAMPLE:
;;
;;
;;CAUTIONS:
;;
;;
;;ASSUMPTIONS:
;;
;;LONG 32 bits (4 bytes)
;;INT 16 bits (2 bytes)
;;CHAR 8 bits (1 byte)
;;
page
pgroup group prog
prog segment byte public 'prog'
assume cs:pgroup,ds:pgroup
public _charop
_charop proc near
push bp
mov bp,sp
mov al,[bp+4]
mov dl,[bp+6]
mov ah,55
int 33
mov al,dl
mov ah,0
pop bp
ret
_charop endp
prog ends
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.