[Tutor] Any ideas

Oscar Benjamin oscar.j.benjamin at gmail.com
Wed Feb 5 12:24:27 CET 2014


On Mon, Feb 03, 2014 at 04:35:58PM -0800, josh Malone wrote:
> Hi, I'm very new to programming and python is my first language. I'm
> currently enrolled in a class at Oregon State University where we are
> taught to program in python. I'm stuck on one problem and i know what i
> want to do... i just have no idea how to write the program. The question is
> as follows
> 
> Consider four missiles initially located at the four corners of a square
> with a side of 100m. Model their behavior if each missile moves with a
> speed of 5m/s in the direction pointing directly at the missile
> counter-clockwise from itself.
> 
> I think i can do most of this, i'm just confused on how to make the spheres
> continually change their direction. I'm assuming it has something to do
> with a while loop or possibly an if statement. Any help you could give me
> would be great! thanks!

You need to give more description about what you're actually doing (or
expected to do) in your code here. I thought I was with you until you
mentioned the spheres.

Are you supposed to make an animation? Is it about numerical integration?

I would probably use numerical integration for this. The simplest way is to
use the Euler method:
http://en.wikipedia.org/wiki/Euler_method

It's common to use the Euler method as a demonstration of how to do dynamic
simulations (a more advanced tutorial might rightly scorn the method as being
inferior to proper integration techniques). Does this seem like what you need
to do?

If you're using scipy then it has a function called odeint that is a good
numerical integrator (better than the Euler method).


Oscar


More information about the Tutor mailing list