• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Need a math question

Status
Not open for further replies.
Level 18
Joined
Oct 18, 2007
Messages
930
Ok im stuck in a spell, as usual... So i need a result that gives me the correct real value that the unit is moved every interval. In the end it will match up to the time. The end result will be ' S ' ( Speed )

The variables you are given is this.
  1. Real value ' D ' ( Distance )
  2. Real value ' T ' ( Time it takes )
  3. real value ' I ' ( Interval )

The object(unit) ' U ' is moved every interval ' I ' with speed ' S ' for a distace of ' D ' over time ' T '.
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
But... if you want the current time, either, just increase a real (lets call it Tinc) everytime you run the loop: At beginning: Tinc = 0, at every loop Tinc = Tinc + Interval
or, if you have the distance increasing every interval: Tinc = Dcurrent/Speed
 
Level 18
Joined
Oct 18, 2007
Messages
930
But... if you want the current time, either, just increase a real (lets call it Tinc) everytime you run the loop: At beginning: Tinc = 0, at every loop Tinc = Tinc + Interval
or, if you have the distance increasing every interval: Tinc = Dcurrent/Speed

no, you dont understand :p I Want the unit to move at a calculated value each interval. It will move a distance over a given time.

Fack, i mean you will not be given a speed :p

( Read the first post again, updated the info )
 
Level 7
Joined
Jul 20, 2008
Messages
377
Oh, I see what this guy wants. Basically, you're given the total distance over which the unit travels and the time it takes for that unit to travel the distance. This guy wants the speed, it's really quite simple.

The unit moves at a rate of 'S' per 'I', right? So if we were to take the number of intervals, 'I', and multiply it by 'S', we would get the total distance. Right?

D = SI, or S = D/I

And obviously,

T = DS, or T = (S^2)I

Did that help?
 
Level 18
Joined
Oct 18, 2007
Messages
930
Oh, I see what this guy wants. Basically, you're given the total distance over which the unit travels and the time it takes for that unit to travel the distance. This guy wants the speed, it's really quite simple.

The unit moves at a rate of 'S' per 'I', right? So if we were to take the number of intervals, 'I', and multiply it by 'S', we would get the total distance. Right?

D = SI, or S = D/I

And obviously,

T = DS, or T = (S^2)I

Did that help?

hmm, not right on the interval thing. The interval is the every sec it moves. If the interval os 0.035 then it will move every 0.035 seconds
 
Level 7
Joined
Jul 20, 2008
Messages
377
So we need to figure out how many intervals there are in the total time. That's T/I.

Let's call the number of intervals, 'N'. Replace I in my original equations by N. You're done.

D = ST/I
S = DI/T
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
Like I said to Dynasti in the chat

S = D / (T * (1 / I))

1 / I - converts the interval to frames per second
T * (1 / I) - time dependent on the fps
D / T - just a normal calculation for speed

Example:
D = 1000
T = 5
I = 0.05

S = 1000 / (5 * (1 / 0.05)) = 1000 / (5 * 20) = 1000 / 100 = 10;

Explanation:
Moves FPS*10 each second = 20*10 = Moves 200 every second = 1000 in 5 seconds.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
S = D*I/T

GhostWolf Optimization FTW.

D*I gets the distance to move per interval update

/T adjusts it to be over the specified time.

S = D*I/T is the same as S = D / (T * (1 / I)) but logically wil be faster as it has no brackets and one less division and number.
 
Status
Not open for further replies.
Top