Copy link to clipboard
Copied
I am new in this expressions and scripting. I want a circular shape layer to move in a projectile path following actual physics formula.
Just using the basic projectile formula, you could do something like this:
g = -55000;
angle = -45;
v0 = 10000;
a = degreesToRadians(angle);
vx = v0*Math.cos(a)*time;
vy = v0*Math.sin(a)*time - g*time*time/2;
value + [vx,vy]
Adjust gravity (g), initial velocity (v0), and launch angle (angle) to get the result you want.
Copy link to clipboard
Copied
for your convinence:
I have considered my screen to be around 30 cm. I am thinking of beginningo f width of my screen to be the starting point and end of screen to be range of projectile. So I have calculated the velocity and time need to reach at that distance at an angle of 45 degrees.
velocity=1.71 ms/s
And as time will be required for the duration of animation,
TIme to reach taht point in that velocity T = 0.246 seconds.
Copy link to clipboard
Copied
My Throw 2d iExpression implements such a formula:
If you want to implement something like this yourself, it will be pretty cumbersome (this iExpression is more than 100 lines of code). If you do a simple, frame by frame simulation, it gets a little bit easier, but tends to calculate very slowly, too.
Copy link to clipboard
Copied
If it does not need to be 100% physically accurate, but much more intuitively and easy to use, my extension Easy Bounce could also be an option (and there is also a pretty powerful FREE version). Technically, Easy Bounce is also based on accurate physics, but since you specify the bounce points of the path yourself, you can provide physically impossible moves and Easy Bouce will still create moves that look plausible instead of rejecting the impossible 🙂
Copy link to clipboard
Copied
Just using the basic projectile formula, you could do something like this:
g = -55000;
angle = -45;
v0 = 10000;
a = degreesToRadians(angle);
vx = v0*Math.cos(a)*time;
vy = v0*Math.sin(a)*time - g*time*time/2;
value + [vx,vy]
Adjust gravity (g), initial velocity (v0), and launch angle (angle) to get the result you want.
Copy link to clipboard
Copied
Wow! Thanks! You are the guy! Don't you have youtube channel or sth where you teach about expressions?
Copy link to clipboard
Copied
You need to be much more specific. No offense, but this is one of those "What does it have to do with anything?" questions. Inside AE physical units don't matter, only pixels. And that being the case, all you are ever going to get out of your calculations are pixel values. Sure, correlating them to physical units by ways of a DPI setting vs. actual physical screen size, but even then measuring your AE comp on screen at crooked zoom levels and without considering the operating system's/ graphic's driver's own DPI calculations is perhaps not that terribly useful. Similarly, the physical velocity would need to be relative to the actual framerate as that's simply how film/ video works and you haven't offered any of this info. Again, I don't mean to be rude, but you need to be much more specific. There's a ton of things to consider here. If you need this e.g. for a large projection and it needs to be reasonably accurate to realworld dimensions, all these details matter. If it is for an explainer video or something, then this may be a whole different story and none of this may even be relevant, as you could simply lable it whatever you want. so for what it's worth, you need to explain what you need this actually for and then we can take it from there. Other than that you can always find some info on how to calculate a ballistic trajectory based on projectile weight, gravity, air resistance and possibly other factors. In fact there may still be that old, old "Tank" game AE project out there that someoen created when expressions were new in version 5 15 years or so ago. You would not be able to open it in a current AE, but since it was a tutorial you could at least learn something from the code bits.
Mylenium