Activity › Forums › Adobe After Effects Expressions › Graphing an equation
-
Graphing an equation
Posted by Tim Johnston on January 23, 2009 at 4:20 pmWhile I know it’s possible to create motion and manipulate other properties by equations, I was wondering if it’s possible to create a path based on an equation in after effects?
I need to graph an exponential curve, but be able to change the variables in the equation. Any thoughts?
Thanks!
Pedro Amaral replied 11 years, 8 months ago 6 Members · 8 Replies -
8 Replies
-
Darby Edelen
January 23, 2009 at 6:54 pmIf you need to display a graph then Write On might be your best option. It can be somewhat irritating to coax the AE coordinate system into a more standard coordinate system, but it’s definitely something you can do. Once you take into account that the upper left corner of the composition is [0,0] instead of the center (or a custom point) and that the y values increase as you move down the code for drawing the graph is pretty simple. You just need to update the y position of the brush based on its x position, for example:
c = [thisComp.width / 2, thisComp.height / 2]; //the center of our graph
g = effect("Grid")("Width"); //this is the size of the grid lines i created for this graph
xs = effect("Scale")("Point")[0] * g; //this is a scale factor to apply to the x values (allowing us to 'zoom' in on the graph)
ys = effect("Scale")("Point")[1] * g; //this is a scale factor to apply to the y values (allowing us to 'zoom' in on the graph)
p = value - c; //this is the location of the write on brush relative to a [0,0] point at our center point
x = p[0]; //the x value
y = x * x; //the y value is where our equation is written
c + [x * xs,-y * ys] //add the scaled x and y offsets to our center point.
Darby Edelen
-
Tim Johnston
January 23, 2009 at 8:09 pmHmmm… perhaps I’m doing something wrong here, but I didn’t get anything to show up.
I created a solid, added the WriteOn, Grid, and ExpressionPointControl which I called ‘Scale’ with a value of [1,1]. I pasted your expression into the expression for ‘brush position’, but I’m not seeing any kind of a graph. Am I missing something here?
Thanks!
-
Tim Johnston
January 23, 2009 at 8:34 pmI found a workaround, but it’s going to be a pain once the equation changes!
1) Write the equation in a spreadsheet to get a list of the data points.
2) Use Illustrator’s graph tool to create a graph based on the data. (have to copy pasted directly from the spreadsheet. I used Apple’s Numbers, and it only saves as Numbers or Excel file, neither of which were recognized by illustrator.
3) Copy the line in the graph, and use window > pathfinder to make a single path from all the little graph points. Copy this path.
4) In AE create a shape layer with a random shape as a placeholder. Click on that shape’s ‘path’ property and hit paste.Still waiting to figure out if it can all be done within AE, though.
-
Filip Vandueren
January 24, 2009 at 12:53 amTry reversing the order of the write-on and grid -effect.
Perhaps the grid is erasing your previous effect. -
Sumanth Peddamatham
January 26, 2009 at 10:25 amI’m not sure if this helps, but Processing (processing.org) has a Illustrator export option. It would only take a few lines of code to create a program to generate .ai files to import into AE. If you’re interested, I could throw something together for you.
-
Sumanth Peddamatham
February 18, 2009 at 6:50 am -
Nick Depp
November 8, 2011 at 6:00 amOkay so here is my problem. For work, I have a curve that I need to put into
excel and find the graphing equation. So I look at the curve and record data points
from the curve into excel. I will then graph the points and it will produce a
curve just like the one have on paper. My problem comes when I ask excel to
produce equations for the curves. The equations it produces do not match the
curves when I enter a value into the equation. Why does this happen or how
can I fix it? -
Pedro Amaral
August 27, 2014 at 11:28 amHey,
I’m trying to do the opposite somehow, I want to get the equations from my graph editor, is this even possible?
Is it possible to get any data from the graph editor?
I’ve also tried to use the expression that Darby posted but couldn’t get anything out of it too.
Thanks
Reply to this Discussion! Login or Sign Up