• 🏆 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!

Aplying physics into WC, need equations

Status
Not open for further replies.
Level 25
Joined
Jun 5, 2008
Messages
2,572
I will be needing the following equations which can be aplied in WC.

Imagine a projectile, you know it's movements speed, it's angle, it's height, and i need to know how would i aply:
a) Gravity
b) colision angle
c) friction
d) colision resulting acceleration

Also let's say the mass of the missile is 100.00.

This is to be aplied in WC3 so if you can reply in the form:
" you need to get the Atan of that radian them multiply it with..."

Will give +rep for the help on this issue.
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
I don't see the necessity of friction, especially for something like projectiles. In order to apply physics you're going to also need to be able to use vectors, which you can declare as a struct with vJass. Gravity is an acceleration of 9.8m/s² but in WarCraft III terms it would probably be about 128units/s².

Collision resulting acceleration is ambiguous, and to my knowledge there is no such field in physics. Collision is a result of momentum, elasticity, and other variables.

There are two angles that you need to look at when dealing with a 3D projectile, because its going to have an XY angle and a YZ angle (elevation angle). It really isn't a simple process. There are plenty of systems to download either here or on wc3c.net that you could examine to see how the math is converted to JASS/vJass code.

To begin with, you're going to need a timer that updates the position of all your objects, as well as adding the "acceleration" values to the "velocity" values (that's how acceleration works). Don't forget that "acceleration" is seconds squared when setting up your acceleration values. In addition to the updating timer, you'll need to be able to reference an entire stack of objects within your update so you'll have to find a method of doing that (I know one but there are plenty of resources to explain this).
 
Level 25
Joined
Jun 5, 2008
Messages
2,572
Thanks for the gravity equation.

Friction should be aplied when the missile touches the ground or is moving on the ground.

Anyway the main thing i need is to know how does an acceleration/velocity of a missile changes upon impact with a plane or another missile if there is such a equation.

About the angles and the resulting angles i fixed all that up with vectors, i just am wondering is there some equation for acceleration/velocity upon a colision or should i just decrease them by some % to make it look realistic.
 
Level 10
Joined
Sep 21, 2007
Messages
517
F = ma --> a = F/m

F is the net force

m is the mass of the object collided

as for the decrease... hmm, i think it depends on the surface and how much friction it has. then i think you can use the conservation of energy of momentum equation. or just decrease it on a periodic time frame based on the frictions value xD
 
Level 11
Joined
Jun 28, 2008
Messages
2,362
That is the simplest formula in physics. We learn that in 6th grade (you slept tro it Kingz xD).

Simple law of action and reaction. Hit something with a force, and hitter will also receive same one. So if object can move it will take the force and move (hitter will bounce back if hit angle is 90 degrees).

So that's what Diehard said.

Just add sin or cos in equation. Need to go have lunch, will tell ya after words exact formula (if I manage to think it tro).
 
Level 25
Joined
Jun 5, 2008
Messages
2,572
Well tbh i don't like maths & physics much and over time you forget stuff :p

If you would ask me to make a computer network or calculate subnets or such that i love doing i would do it in a second ^^

Also i figured some of the equations are easy but i am interested how to aply them in WC3.
 
Level 11
Joined
Jun 28, 2008
Messages
2,362
Oh, and just so you know, in collision, shape of object and its bounciness (elasticnost srb.) take in. So, ye its hard. I think its best to just take that its a sphere. Pool has ideal one (Sticks and balls on green covered table).

And you have kinetic energy transfer. Because some is lost. Just using a=F/m formula won't lose any energy, objects will move for ever.

So you will need mass of every object, its speed, energy, elasticity...

As for putting it in, you know Jass. I could do it in pascal without using normal signs (+, -, /, *)(cuz pascal has them, but jass doesn't).

EDIT: http://gmc.yoyogames.com/lofiversion/index.php/t454449.html I found this. Its if objects are round. Aldo it doesn't take angle in to account. Hope it helps.
 
Level 11
Joined
Jun 28, 2008
Messages
2,362
I didn't. Just found that on Google :p

And, that's best formula that you can get, without getting too complicated. Good luck with the project and stuff.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
There should be no change in acceleration when a unit collides with anything, the acceleration is simply due to gravity. When an object collides with the terrain, the angle of inflection (bounce-pattern of the colliding object) will be a result of a vector rotation around the terrain "normal" vector.

A normal vector is a vector that is perpendicular to a plane.
 
Level 11
Joined
Jun 28, 2008
Messages
2,362
That is when when only 1 is moving. Is that what he meant. I thought its 2 moving (or at least 1 moving and one not nailed down).objects colliding each other.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
It doesn't matter, collision doesn't create a force. A force can only be created by mass or charged particles (gravitational field, magnetic field, respectively). Two objects colliding does not create a force-field, therefore there is no force, therefore there is no acceleration.
 
Level 11
Joined
Jun 28, 2008
Messages
2,362
I didn't say force is created, I said its lost. And I mean F with Newton [N]. Not some force field. I meant F as in vector. Every speed, acceleration, electric or magnetic field has force.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
HailFireer said:
I didn't say force is created, I said its lost. And I mean F with Newton [N]. Not some force field. I meant F as in vector. Every speed, acceleration, electric or magnetic field has force.

The force you're thinking of is from like the impact of an object rather than just some mysterious "acceleration" which is what gravity is. But, when two objects collide I don't think that the acceleration is important, I think that its the momentum you need to be worrying about.

Momentum = Mass × Velocity
 
Level 11
Joined
Jun 28, 2008
Messages
2,362
Colliding can either stay same at velocity or lose. It can't gain it in any scenario.

Think of it if you run fast in to the wall directly, apart from huge pain, you will be stopped, maybe fall back if you are going fast enough. If you do it in an angle you will be able to push off the wall and continue running little slower (Aldo you can increase speed cuz your muscles allow it, normal object can't.
If you hit something softer and elastic, you will also stop, but will be thrown back more.

But if object is elastic enough it will bounce off wall at same speed (like a tennis or basket ball).

Bullets bounce off walls (or penetrate them), aldo they are lead which is heave and not elastic, speed is so great that force applied to wall goes back to it and pushes it back.

Njutnov drugi zakon - akcija i reakcija (sry for srb, I don't know how to say it in English).

So its, how fast you impact something, how elastic either of thos things are, and mass.
 
Level 11
Joined
Jun 28, 2008
Messages
2,362
When it impacts terrain, just make it bounce off at same angle it came in. Aldo for long distance, you need to make it slow down.

And I said sorry to other people who read. I know where you are from ^^
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
baassee said:
isnt gravity formula 9.82m/s2?

You should read the thread.

Kingz said:
So coliding with a normal terrain plane shouldn't affect the acceleration of the object while coliding with a difrent object should increase it's momentum and therefore increase it's velocity?

By definition acceleration is a change in velocity. When a ball bounces off of the ground, the direction of its velocity changes, so by definition that was an "acceleration". When you're coding it though there will be no acceleration that you have to account for other than Gravity.

If object A has a mass of 10 and object B has a mass of 10, and object A (moving) hits object B (stationary) at a velocity of 50m/s, then due to the conservation of momentum object A will be stationary while object B now has a velocity of 50m/s. By definition, the velocity of both objects is changing and therefore there is an acceleration, but like I said before you're not going to worry about it when you're coding.
 
Level 11
Joined
Jun 28, 2008
Messages
2,362
Barbanog, That A and B is true but only if hit is direct. If you juts hut it on side (like in pool, where you make white ball touch some other on side to make it go left or right while wight one still has its speed left).
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
The net velocity will still remain the same.

I gave you an example where the collision angle and the movement angle were the same. If they were different then you could use trigonometry to break it down into X/Y components.
 
Level 11
Joined
Jun 28, 2008
Messages
2,362
Ye sinus and cosinus. And ye overall speed remains the same.

So to summer it up, if it hits a large unmovable object it bounces off at angle it cam in.

If both are movable hitted project also starts to move, while moving slows down. How much depends on angle. 90 moving stops, hitted starts moving. Lesser the angle, lesser is the transfer.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
The angle that they reflect off of each other is based on the angle between them. If the angle between the colliding objects and the angle of the movement is 0 then the velocity will transfer entirely (if the object is not moving).
 

Attachments

  • CollisionDiagram.jpg
    CollisionDiagram.jpg
    22.5 KB · Views: 91
Status
Not open for further replies.
Top