Creative COW SIGN IN & SETTINGS :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE AFTER EFFECTS: ForumAE BasicsAE ExpressionsTutorialsArticlesPodcastsMotion GraphicsTrainingCinema 4D

Re: Error with gravity expression

Cow Forums : Adobe After Effects Expressions
VIEW POSTS   •   ADD A NEW POST   •   SEARCH   •   CHANGE FORUM
Return to Posts Index   •   Read Entire Thread   •   Reply To This Post


Re: Error with gravity expression
by Darby Edelen on May 12, 2008 at 12:10:54 am

Also, I thought I'd take this space to mention that I wrote a little expression that will take keyframed values and add an exponential decay to the end of the keyframes... This is a derivative of something Dan did on his site, so credit is due, as usual, mostly to Dan =)


n = value.length;
if(numKeys > 1){
firstKey = key(1).time;
lastKey = key(numKeys).time;
v = velocityAtTime(lastKey - thisComp.frameDuration);
a = 20;
decay = 2;
f = 1/a;
t = Math.max(time - lastKey, 0);
x = a * Math.sin(v[0] * t * f) / Math.exp(decay * t);
y = a * Math.sin(v[1] * t * f) / Math.exp(decay * t);
z = a * Math.sin(v[2] * t * f) / Math.exp(decay * t);

value + [x,y,z];
}
else value;


This doesn't work for something bouncing off a hard surface like a floor, but it works well to simulate springy motions. In the above you may want your own values for 'a' and 'decay.' The above is for a 3 dimensional vector (such as 3D position or 3D scale). For a scalar value (1 dimensional like rotation) you would use:


if(numKeys > 1){
firstKey = key(1).time;
lastKey = key(numKeys).time;
v = velocityAtTime(lastKey - thisComp.frameDuration);
a = 2;
decay = 2;
f = 1/a;
t = Math.max(time - lastKey, 0);
x = a * Math.sin(v * t * f) / Math.exp(decay * t);

value + x;
}
else value;


Darby Edelen
Lead Designer
Left Coast Digital
Santa Cruz, CA


Return to Posts Index   •   Read Entire Thread   •   Reply To This Post


Current Message Thread:




Note: If you are a registered user and you do not see your name and email in the two respective fields above, you may reset your account cookies by clicking here. Your post will not be accepted if the name and email provided above are not currently registered in our database.

Name
E-Mail Address
Subject
E-Mail me when someone responds
Just This Message   Entire Thread   None  


Message                Add Bold Tag To Message (JavaScript required)

To put any item inside this tag:

1. Highlight the desired text
2.Click this buttonAdd Italic Tag To Message (JavaScript required)

To put any item inside this tag:

1. Highlight the desired text
2.Click this buttonAdd Underline Tag To Message (JavaScript required)

To put any item inside this tag:

1. Highlight the desired text
2.Click this buttonAdd Image Link Tag To Message (JavaScript required)

To put any item inside this tag:

1. Highlight the desired text
2.Click this buttonAdd URL Link Tag To Message (JavaScript required)

To put any item inside this tag:

1. Highlight the desired text
2.Click this button

Note: The following characters are HTML command characters, and may cause parts of your post to disappear, if not used correctly: < > &. To include any portion of the post in your response, highlight the desired text and hit the "Q" key. For more on how to post, click here.


Add your message signature


 


Note: By clicking "Post Direct" button above, you are agreeing to the Creative Cow's Code of Conduct.



FORUMSLIBRARYPODCASTSBLOGSMAGAZINESERVICESNEWSLETTERSNEWSSTOREEVENTS

© CreativeCOW.net All rights are reserved.

[Top]