Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Integral Calculus in AE

New Here ,
Aug 25, 2011 Aug 25, 2011

I'm wondering if there is a way to add the values of a property for every frame before the current time indicator?

the relevance to calculus:

I'm wondering if there is a procedural way in after effects to calculate the area under a curve for a property (integrating the function from "time a" to "time b"). for instance, if you had a slider that you keyframed to have a value of 1 for 3 seconds, a value of 10 for 1 second, and again a value of 1 for 3 seconds (with Hold Keyframe on in this example, but not necessarily so in all other instances). after the 7 seconds in the example, the area under the curve (finite integral from "time 0" to "time 7") should have a value of 16 (if i did my math correctly)

if there is a way to do this, will it work on, for instance, a slider with key frames like the one above, with NO Hold Keyframes, and with easy ease applied to the keyframes? essentially, could it work on any property with any shaped curve?

thanks, i hope i didnt confuse people too much with my question

TOPICS
Expressions
3.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 25, 2011 Aug 25, 2011

Wow, that's an interesting situation.  I don't know if there's a way to do it in AE -- I suspect it can't easily be done, if at all -- but I'm more interested in how you'd use this information.

At the moment, the only thing that comes to mind would be calculus training videos, with motion graphics made in AE.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 25, 2011 Aug 25, 2011

really all i need is a way to add the values from each frame of a property before the current time indicator. yeah i havent been havin much luck on it. i did however find a site that has something that could help. for each frame, it looks backwards to the beginning for a certain situation and records how many instances of that situation are. it's above me how it does it, but it seems like it's on the right track.

http://www.motionscript.com/design-guide/audio-count.html

the purpose: i'm looking for a way to achieve this kind of random motion with the wiggle expression.

http://www.youtube.com/watch?v=7c4WYzr30B0&feature=BFa&list=PL3D65D166031E0E2B&lf=plpp

to achieve this i thought i might keyframe the frequency of the wiggle expression. this ran into a problem, because the frequency determines precedurally where on the path the values whould be wiggled. therefore while increasing the frequency, it will appear as if the frequency of the wiggle is much greater than desired. and a more funky thing happens when the frequency decreases. the wiggle will retrace its steps exactly where it came from.

i dont want to keyframe the amplitude on and off because that would mean every time the amplitude =0, the origin of the particle emitter (or whatever you want to have the random motion) would go back to it's original value. i want it to keeps its amplitude, but have a point zoom across the frame while the frequency is high, PAUSE THERE when the frequency is 0, and then resume motion from that point when the frequency is increased again.

i had an apiphony about achieving this. i've tested it on paper and as far as i can tell it will work, but to test it in after effects i need a way to integrate (or simply add all the previous values to find the "area under the curve")

if there's another way to procedurally achieve this kind of random motion, that would be amazing!!! but i still reeeeeeaaaallly would like to figure out this integration thing.

thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 25, 2011 Aug 25, 2011

Yes, you will have to use an expression as per Dan's example.

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 26, 2011 Aug 26, 2011

do you know where i can learn how to apply dan's expression techniques to the integration effect i'm trying to achieve?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 26, 2011 Aug 26, 2011

This is a simple example that samples every frame:

accum = 0;
for (i = 0; i <= timeToFrames(); i++){
  accum += valueAtTime(framesToTime(i))*thisComp.frameDuration;
}
accum

You could have it sample more often to improve the accuracy, but this is probably close enough for most applications.

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 26, 2011 Aug 26, 2011

Thank you Dan! you are a miracle maker!

for my purposes this expression works superbly!!

does your "mastering expressions" guide on motionscript.com explain how to construct expressions such as these? also the expressions in your "expressioneer's design guide" are quite above me. does it go into that? nowhere have i found a place that explains expressions such as "for (i = 0; i <= timeToFrames(); i++)"

Thanks again

Ramzi Rebeiz

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 26, 2011 Aug 26, 2011
LATEST

The for loop is part of core JavaScript. If you're at all serious about this stuff, you need a good JavaScript reference. I like David Flanagan's "JavaScript the Definitive Guide" (it's the most worn book in my library), but there a lot of good references out there.

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines