4 Replies - 432 Views - Last Post: 05 May 2009 - 09:13 PM

#1 computerfox   User is offline

  • straight vegetarian kid

Reputation: 50
  • View blog
  • Posts: 3,772
  • Joined: 29-January 09

Newtonian Position

Posted 03 May 2009 - 08:30 PM

Description: a=initial position b=initial speed c=acceleration d=time
//add this before the main method

public static double newtPos(double a, double b, double c, double d){

double position;

position=a+(b*d)+(.5*c*(d*d));

return position;
}

//enjoy!!!

Is This A Good Question/Topic? 0
  • +

Replies To: Newtonian Position

#2 SciCoder   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-May 09

Re: Newtonian Position

Posted 05 May 2009 - 07:49 PM

Depending on context, this sort of function may be called a LOT, so you can optimise a little. At first glance, and with standard physics variable names, could try: /** * @param s0 initial position * @param u initial velocity * @param a acceleration * @param t time at constant acceleration * @return position at t */ public static double newtPos(double s0, double u, double a, double t) { return s0 + (u + .5*a*t)*t; }
Was This Post Helpful? 0
  • +
  • -

#3 computerfox   User is offline

  • straight vegetarian kid

Reputation: 50
  • View blog
  • Posts: 3,772
  • Joined: 29-January 09

Re: Newtonian Position

Posted 05 May 2009 - 07:51 PM

haha yeah i know, i was just too lazy sorry :D
Was This Post Helpful? 0
  • +
  • -

#4 SciCoder   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-May 09

Re: Newtonian Position

Posted 05 May 2009 - 08:49 PM

no problem, it was my first code comment, and i'm trying to gauge what is helpful - i'd better layout my code next time too. ;)
Was This Post Helpful? 0
  • +
  • -

#5 computerfox   User is offline

  • straight vegetarian kid

Reputation: 50
  • View blog
  • Posts: 3,772
  • Joined: 29-January 09

Re: Newtonian Position

Posted 05 May 2009 - 09:13 PM

thank you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1