• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Mathmatics Genius help!

Status
Not open for further replies.
Level 18
Joined
Oct 18, 2007
Messages
930
Mathmatics help!

Need to calculate that if the number is high the end value is low, but not to low

I need this calculation really bad for my slide effect.

Example:

Lets say a radius of 300 around a point, and a unit has the distance 172. from it to the center of the point.

!( If the unit is at 0 distance the End value needs to be 5 "Can be 6" if it is at 300 then the end value should be 0)!

The Unit will move the end value every 0.01 Secconds!

Tip for calculation: In the end, all units should be in the exact distance from the unit to the center point!!

what do i need to calculate in the Trigger Editor to get the right value??

[+] rep will be given to the one that solves this :wink:

Here is the map if that would make it any better (Edit: Updated the test map for more advanced Testing)
THE MATH VALUES IN THE MAP ARE NOT CORRECT, THE MATH PROBLEMS IS WHAT YOU NEED TO SOLVE!
 

Attachments

  • Test.w3x
    21 KB · Views: 41
Last edited:
Level 21
Joined
Aug 9, 2006
Messages
2,384
Firstly, explain better, i think it is hard to understand... try to explain better... you want if the unit is closer to the middle of a circle the number should be higher as when the unit is far away?

And you should learn to write, its called E !X! ample.


Hm, do you need a decrementing knock back speed?

And if you need that, is the distance fixed? Means, it is always 300 or?






WHAT A SENSE MAKES THIS!? Why should all units be in the same distance...

Well, I will leave this thread, it is non-sense, if you dont explain something...
 
Level 21
Joined
Aug 9, 2006
Messages
2,384
Distance left = Radius-"Distance between unit and the middle, the point 0(zero)"

Speed loss per 0.01 = Distance left/Number of Steps(0.01 ticks)

For example, the radius is 300 diameter, and the unit is at 172 (your example).

300 - 172 = 128 (Our distance left).

128 diameter/0.01 is your start speed.

Lets say 20 steps, 20 times the speed decrements.

128/20 = 6,4.


Means the speed starts at 128 and decrements per 0.01 seconds by 6,4, then it is in 20 steps at 0.



Thats a smooth decrementing speed. I hope I could help you. If you use that formula, units could not leave the 300 diameter radius, useable for all radius ranges.

For smooth and slow decrements increase the steps ;D.


EDIT: theres a problem, the start step is too high... dunno how to fix it.
 
Level 18
Joined
Oct 18, 2007
Messages
930
Distance left = Radius-"Distance between unit and the middle, the point 0(zero)"

Speed loss per 0.01 = Distance left/Number of Steps(0.01 ticks)

For example, the radius is 300 diameter, and the unit is at 172 (your example).

300 - 172 = 128 (Our distance left).

128 diameter/0.01 is your start speed.

Lets say 20 steps, 20 times the speed decrements.

128/20 = 6,4.


Means the speed starts at 128 and decrements per 0.01 seconds by 6,4, then it is in 20 steps at 0.



Thats a smooth decrementing speed. I hope I could help you. If you use that formula, units could not leave the 300 diameter radius, useable for all radius ranges.

For smooth and slow decrements increase the steps ;D.


EDIT: theres a problem, the start step is too high... dunno how to fix it.

I mean like it always move to the same distance, lets say a unit with 100 distance will travel the same distance as the unit at 200 distance, the differences between those units are the start speed, like you said: Dunno how to fix the start speed
 
Last edited:
Level 18
Joined
Oct 18, 2007
Messages
930
More Info

Some of the big problem is that if you "/" with 50 or 20 or any number the number does not get exact to the value that i want to make every unit move to the same distance in the end.

Example:
a unit is at 172
then someone thinks: Lets "/" it with 50. they get 3.44.
Then i say try to do that with a lower number like 85 and see for ureself if it goes as long as it Should be. Test it for ureself unitll you find a solution.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Thankfully a field called physics was invented which is suited to solve the problem non linarly.

As you have a S , a, v, all you need to do is find u, the initial velocity (u) at which the unit gets launced away from the centre.

u^2 = -2as

Initial velocity squared = negitive 2 times acceleration times displacement.

s = 300-distance from centre
a = any negitive number if displacement is positive.

This does not mean they all reach their endpoint at the same time, this does however mean all approximatly reach 300 units away from the centre. I have tried and tested it and it does work with only a 1% error in final distance (300-303 units away from centre) due to the inaccurate way decelleration is applied (in bursts and not in a linial way). The timer however has a problem meaning it often does not give the unit enough time to travel so it ends occasionally before it reaches the end distance. The maximum time taken is 140 odd tick of movements.

I recomend removing all group leaks if you want your map to remain playable.
 
Last edited:
Level 12
Joined
Apr 27, 2008
Messages
1,228
How about S=V*t - 1/2 *a * t * t. I think it is kinda better for this situation.

Do not expect to get accurate results with a wait...
In GUI, use another trigger.
 

Attachments

  • blaha.w3x
    20.7 KB · Views: 32

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
spiwn, wrong formula (yours is incorrect).

S = ut+at2/2

If this was a physics exam, you would have lost marks lol.

Anyway, that formula is unefficent. You should just be able to use. . .

s = (v2-u2)/2a

Where v = last velocity - acceleration
u = initial acceleration
a = acceleration.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
No, it is correct.
Look carefully ()
Hm, in you physics exam, your teacher would be very surprised of the acceleration that changes.
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Both of you, shut up. Anyway, here are the 4 kinematics formulas, use them as you will. Also, you will not contradict me, I am correct:

Δs = vit + at2/2
vf2 - vi2 = 2aΔs
Δs = (vi + vf)t/2
vf = vi + at

Where Δs is variation in position
a is acceleration (uniform)
v is velocity (f and i subscripts indicate final and initial, respectively)
t is time elapsed

I don't even know if these can be useful in this thread's situation because I don't understand a word of what needs to be done. But yeah, just to clear shit up, those are the 4 kinematics formulas.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
HINDYhat, I believe they were spammed enough, you basically just repeated the one I used in that list. And yes I will contridect you and tell you to shut up as I basically already told him the right formula in a more understandable way.

spiwn, your formula seems to be the inverse of the first one on hindy's list where you basically used v instead of u. So you were correct but it is a funny way of putting it. Still mine is probably more efficent as you do not need to count time.
 
Status
Not open for further replies.
Top