My Math Forum  

Go Back   My Math Forum > High School Math Forum > Algebra

Algebra Pre-Algebra and Basic Algebra Math Forum


Reply
 
LinkBack Thread Tools Display Modes
February 9th, 2012, 04:00 PM   #1
Newbie
 
Joined: Feb 2012

Posts: 2
Thanks: 0

incease speed and changing direction.

hey
i'm a game developer not so good in maths
so i thought i come ask some advice here...

what i basically need is a formula that can increase in both positive and negative with using one variable that changes from minus to plus.

my code is this

speed +=1
speed= -speed

the problem here off course is that is does the following on update:

speed = 5 + 1
5+1 = -(5+1)
which is good (my object changes direction and goes 1 faster)
then the second time

speed = -6 +1
-5 = 5
my direction changes but my speed goes down one...

now is there a way i can get the number increased in the part where it says speed = -6 +1 so it results in - 7 and the next run would be 7+1 and so on...?
don't even know if this is a stupid question or not i just can't figure out how to get it to work with in one formula...

so any pointers are welcome
thx J.
rottjung is offline  
 
February 9th, 2012, 04:17 PM   #2
Senior Member
 
MarkFL's Avatar
 
Joined: Jul 2010
From: St. Augustine, FL., U.S.A.'s oldest city

Posts: 12,155
Thanks: 464

Math Focus: Calculus/ODEs
Re: incease speed and changing direction.

Instead of adding 1 to the current speed, you could add abs(speed)/speed so that if speed < 0 then -1 is added and if speed > 0 then +1 is added.

Note: abs(x) = |x|, the absolute value function.

Your programming language should have that intrinsic function.
MarkFL is offline  
February 10th, 2012, 07:10 AM   #3
Newbie
 
Joined: Feb 2012

Posts: 2
Thanks: 0

Re: incease speed and changing direction.

thanks!
it has this Mathf.Abs
didn't think of looking in the mathf functions, grrr stupido!
rottjung is offline  
Reply

  My Math Forum > High School Math Forum > Algebra

Tags
changing, direction, incease, speed



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find the ratio of his usual speed to his speed that day. Chikis Elementary Math 25 January 31st, 2014 09:48 AM
force and direction Melody2 Physics 2 October 28th, 2013 04:44 PM
Need a little direction.... Aimee-D Advanced Statistics 1 July 26th, 2012 05:10 AM
Speed and Direction C42711 Algebra 0 October 30th, 2011 01:06 PM
Jet Speed & Wind Speed RMG46 Algebra 1 July 5th, 2010 10:36 PM





Copyright © 2018 My Math Forum. All rights reserved.