PDA

View Full Version : need help with physics


connman
12-30-2005, 05:22 AM
i'm currently doing a programme where the user aims the bow from 0 - 90 degrees in any angle...

when he shoots the arrow... the arrow flies, and it's affected by gravity as well... meaning the arrow will drop because of gravity...

cann anyone help me in dis bow and arrow physics???
thnx...

Sunny13
01-01-2006, 05:07 AM
why not you just find the formula on the net itself
here is one such site that can help you
http://www.staff.amu.edu.pl/~romangoc/M2-1-projectile-motion.html

quarkenzyme
01-05-2006, 06:20 AM
wow, i love programs that imitate physical properties. its probably the reason why i got started in programming in the first place.

anyway, that sounds like a nice program. simple, but functional, and it mimics laws of physics.

some advice that might help you with this program:

an arrow that is lauched in the air from a bow travels in an arc wich is called a 'trajectory'. the curving shape is formed by horizontal and vertical motion. take note that horiz and vert motion are separate, even though they can be in effect on the same object, and they change and react separately, independently of each other. also when dealing with physics, its always important to keep in mind the different forces that are acting upon the object. what propels the object horizontaly? only the bow pushing it to the side. (unless you factor in air friction, but since its so small, its usualy ignored) so the horizontal motion continues steadily without slowing down or speeding up. then what forces are affecting the object vertically? the vertical force of the bow pushing is slightly upward, and gravity, pulling it slowly downward. since the initial force of the bow is stronger than the pull of gravity, the arrow starts moving upward. but since the force of gravity is continuous, it eventually begins to slow it, and eventually pull it downwards until it hits the ground, and stops it all together...

also take note that there is only one value that represents the force initally put on the arrow, but the motion is divided into horizontal and vertical movement. so how do we derive the two values from the one? well, thats where the formulas come into the picture. i dont know them off the top of my noodle... you can probably find them online, or ask them from your school's physics teacher... but i know it uses trigonometric fuctions. it also takes into consideration the angle at which the object is launched. so you'll have to boil up a formula that uses the angle which the user has the bow adjusted to, and the force at which he intends to launch it. or if you like, the launch force could be a preset, and the user only has control of the angle. you 'a do whatever ya' want.

that is the purely physical aspect. as for the actual programming:
you'll probably want to create two variables. one for the horizontal movement, one for the vertical. the initial values for the variables are the two values derived by the formula. the variable for horizontal motion will stay the same for the whole jouney of the arrow across the screen. but the upward motion will slowly decrease untill its moving rapidly downward. you can acheive this effect by simply continuously lowering the Y coordinate of the arrow at an increasing rate.

finally, keep in mind that the Y axis on macromedia flash MX is opposite the standard position. moving downward is and increasing value, and upward is decreasing in value. it also makes positive rotation clockwise, and negative counter clockwise. i dont know why they did that, it makes it confusing, but thats how it is.

i hope i helped a little bit. let me know if you have anymore questions, and il try to clear 'em up for you. make sure you show me the final result, OKAY!?!?!

GOOD LUCK!:cool: