Physics Formula

wraithseeker

Tired.
Reaction score
122
If I were to give time and displacement as user inputted variables, which formula should I use to get vi and vf?

I tried to derive formulas from here but to no avail :eek:
 
Last edited by a moderator:

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Velocity = Displacement/time

Vi = Initial velocity
Vf = Final velocity

Vi is counted at the starting and Vf is counted at the end.

This is what I had learn in my physic class.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
If you're using the variables of time, displacement, vi, and vf, you would use the formula relating those:

d = ((vi + vf)/2)*t

Solve for vi and vf and you get:

vi = 2d/t - vf
vf = 2d/t - vi

You cannot solve vf or vi from simply inputting time and displacement, because 2 leftover variables means not enough information has been plugged in to get a definite answer.

It of course gets much more messy if acceleration isn't constant though, since then vf is equal to vi plus the integral of a(t)dt evaluated from ti to tf.
 

wraithseeker

Tired.
Reaction score
122
accleration is constant and is the value of gravity.

So I need something like time, displacement and initial velocity?

EDIT: Wait no, final velocity is always 0 becaus I am making a jump.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Or time, displacement, and final velocity, to get initial velocity, yeah.
 

wraithseeker

Tired.
Reaction score
122
But final velocity is always 0 for a jump or a knockback.

EDIT: How about taking only time? I will only move the unit by the Z axis and not touch x & y.

EDIT: I did some hand written stuffs shouldn't equation be

vi = ((2*d)-vf)/(t*t)
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Well, sort of. It's 0 after impact with the ground, but that means you just ditched constant acceleration. Assuming no air drag occurs and the total change in displacement is 0, final velocity should be equal to the velocity at the begining of the jump.

I'm not entirely sure what to get at though, what exactly do you need the numbers for?
 

wraithseeker

Tired.
Reaction score
122
JASS:
private function Periodic takes nothing returns nothing
    local integer i = 0
    local Jump d
    loop
        exitwhen i >= Count
        set d = FlyZ<i> // gravity = -981. TIMEOUT = 0.03
        set d.vz= d.vz+ 0.5 * d.gravity * TIMEOUT
        set d.vi= d.vi+ d.vz *TIMEOUT
        call SetUnitFlyHeight(d.target,d.vi,0.0)
        if d.vi &lt; 0. or GetWidgetLife(d.target) &lt;= 0.0451 then
            call d.destroy()
            call d.Code.execute(d.target)
            set Count = Count - 1
            if Count &gt; 0 then
                set FlyZ<i> = FlyZ[Count]
                set i = i - 1
            else
                call PauseTimer(Timer)
            endif
        endif
        set i = i + 1
    endloop
endfunction

function Heh takes unit u,real displacement, real time returns nothing
   local Jump d
   local real velocity = 0.
        if IsUnitInGroup(u,HitGroup) then
            set d = Jump<u>
            set velocity = 2.00*displacement/time - 0.00 // yr formula
            set d.vz = d.vz+velocity
        else
            if Count == 0 then
                call TimerStart(Timer,TIMEOUT,true,function Periodic)
            endif
            set velocity = ((2.00*displacement)- 0.00)/(time*time)  // err.. the formula im trying to test.
            call BJDebugMsg(R2S(velocity))
            set d = Jump.create(u,velocity)
            set Jump<u> = d
            set FlyZ[Count] = d
            set Count = Count + 1
            call GroupAddUnit(HitGroup,u)
        endif
    endfunction</u></u></i></i>


I took out parts of my jump library.

How did I ditched constant accleration? No air drag, a free fall and displacement is not 0 as the unit is moving to a direction and not coming back.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
I'm assuming you're talking about z velocity, and, in that case, assuming that a unit is stationary when it lands means you are ditching constant accelleration. When an object is at rest on the ground, it has no z accelleration. When it is propelled into the air, extreme nigh-instant accelleration gives it a high velocity in the positive z direction. In the air, the object suffers from a strong gravitational accelleration in the negative z direction. When it's about to hit the ground, its z velocity will be roughly equal to its initial z velocity but in the negative z direction. Upon striking the ground, it suffers VERY HIGH accelleration to stop its descent.
Thus, non-constant accelleration.
This is, of course, unless the jump ends at the maximum z height, at which point vf is indeed equal to 0.



Also, I don't need to see the code. Rather, what is the 'velocity' variable representing? Initial upward velocity? That's the question.
Also, usually in jumps, vi and vf aren't really used, rather it is simulated bit by bit with something derived from:
(delta)s = Vi*t + .5at^2
 

wraithseeker

Tired.
Reaction score
122
That velocity variable represents initial velocity so the unit will fly up and down automatically.

EDIT: Yes I am talking about the Z axis.
EDIT2: How would I do it if I have no constant acceleration? My knockback reduces speed by decrement every interval tick period of 0.03.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Ok, in that case, if you're going to use that formula, use the formula assuming values at halfway through the jump (when the unit is at its highest)(this is so that (delta)d isn't 0, since all that does is create a condition where the only requirement is that Vi = -Vf and thus the equation is useless); d will be the max jump height, Vf will be 0 at that height, and t will be half of the total time for the entire jump:
Thus, considering the lack of Vf:

Vi = 2d/t
 

Rainther

I guess I should write something of value here...
Reaction score
61
I'm not quite sure how a jump would be simulated however, my method would be:

JASS:
function timer takes nothing returns nothing
//Get data
local MaxHeight = 150
set data.integer = data.integer + 1
call SetUnitFlyHeight(data.unit, ( MaxHeight * 4 * data.integer / TurnOff ) - ( MaxHeight * 4 data.integer * data.integer / TurnOff / TurnOff ), 0)

if data.integer &gt;= TurnOff then //Turn off can be Distance of the 2 points divided by the movement occured of the unit each intervall
//Destroy Timer
endif
endfunction

I know I've posted this before, but haven't received any responds.

This is a rather easy way to make a unit fly. It's possible to make the unit fly faster at start, or slower are start.
 

wraithseeker

Tired.
Reaction score
122
@Rainther I don't really understand what you are doing though.

Vi = 2d/t

Did not work too well, the unit flew too high and the knockback long ended
 

Rainther

I guess I should write something of value here...
Reaction score
61
Lemme try to explain. data.integer will eventually reach the same value as TurnOff.

Meaning that data.integer / TurnOff will eventually become the value 1.

So ( MaxHeight * data.integer / TurnOff ) will at the end become only MaxHeight. ( MaxHeight * (data.integer / TurnOff = 1) )

Same thing goes for ( MaxHeight * data.integer * data.integer / TurnOff / TurnOff ) which also will become only MaxHeight, however is does this at a slower speed since the values multiplied with themselves get's lower. x < 1 gives x * x < x

When we are half way through the flying it'll be (MaxHeight * 4 * (data.integer / TurnOff) = 0.5)) - (MaxHeight * 4 * (data.integer / TurnOff) = 0.5) * (data.integer / TurnOff) = 0.5)) which is the heighest we'll reach.

That's why I do MaxHeight times 4. Because MaxHeight * 0.5 - MaxHeight * 0.25 = MaxHeight / 4

And at the end they'll become (MaxHeight - MaxHeight = 0) The orginial height.

EDIT: Seperated it so it'd be easier for the eye :D
 

Strilanc

Veteran Scripter
Reaction score
42
If the jump starts and stops at the same height (ie. flat ground), then you also know that the initial z velocity is opposite the z final velocity:

Vz(final) = -Vz(initial)

So our total change in velocity is 2*Vz(initial), caused by acceleration from gravity over time:

g*t = 2*Vz(initial)
t = 2*Vz(initial)/g

Half way through the jump the unit will be at its highest point, which is:

dz = t/2*Vz(initial) - g*(t/2)^2/2
= 2*Vz(initial)/g/2*Vz(initial) - g*(2*Vz(initial)/g/2)^2/2
= Vz(initial)^2/g - Vz(initial)^2/g/2
= Vz(initial)^2/g/2

Put it all together:

Vz(initial) = sqrt(2*dz*g)
Vz(initial) = t*g/2

You can't specify both the time and the height; only one or the other. If you mean the actual distance d the unit will travel, then just set the unit's speed along the ground to be d/t.
 

Light Alkmst

New Member
Reaction score
20
If it's user inputted, then vi should be given. :D

Otherwise, you could essentially start with whatever vi you want... :D


EDIT:
If I were to give time and displacement as user inputted variables, which formula should I use to get vi and vf?

My bad.

vi * vi = vf * vf - 2 * a * d
Hmm...that's still 2 vars we don't have...
 

Strilanc

Veteran Scripter
Reaction score
42
What do you mean it displayed negative values? If you don't even understand the effects of changing the sign of gravity then I'm not sure I can help.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top