| # 3D curves and surfaces mathematically defined• | **3D curves and surfaces mathematically defined**
on Apr 2, 2019 at 12:56:07 pm |
Hi !
This morning, full of naive optimism, I tried to draw a 3D curve using createPath() in an expression on a shape layer ... As you already know, it didn't work as a layer, by definition, is a 2D container. But still the question remains :
**How can I draw a mathematically defined curve in 3D ?** ( it sounds like an easy thing written like this ... but ... )
I will have to draw lots of them, and sometimes in order to draw **surfaces** ... **mathematically defined** too. ... and **animated** as time will be a parameter in all these definitions.
If I could use my beloved depth of field ... it would be perfect.
I heard that some third party expensive plugins could help to do the job like Trapcode ( which is far from being free ) .
In fact the question is simple :
**What must I learn, what must I buy ?**
( ... and therefore what must I sell to afford the buy ... )
THANKS ! • | **Re: 3D curves and surfaces mathematically defined** on Apr 4, 2019 at 3:33:00 pm |
After some search, I found some options that look interesting but I would like to have a more experienced user's opinion before throwing myself into the process of learning.
1°) I would use blender and Python scripting to generate OBJ animated models of my curves, surfaces or objects. Then I would export the animated OBJ to After Effects :
Create a 3D model using blender and python scripting [Community Environment...
2°) Then I could use Trapcode Form to display my OBJ in a variety of ways ...
https://www.redgiant.com/user-guide/form/base-form-obj/
3°) C4D could also let me display the animated OBJ. But ... I would lose depth of field, am I right ?
Any comment or advice ?
Thanks • | **Re: 3D curves and surfaces mathematically defined** on Apr 5, 2019 at 2:01:47 pm |
Processing is another possible method for generating OBJ sequences mathematically. Based on reading the manual, I haven't actually attempted it.
Other options for rendering 3D OBJ sequences with depth of field in After Effects include Element 3D and Stardust.
Kalleheikki Kannisto
Senior Graphic Designer
• | **Re: 3D curves and surfaces mathematically defined** on Apr 5, 2019 at 2:58:00 pm |
Hi Kalleheikki, Thank you for your answer.
In fact it is the first time I hear about Processing. ... is it "better" than Python within Blender ... ?
I didn't know that Element D could render Depth of field ... as I read many times that it is very basic compared to Cinema 4D ... good to know.
I have also read a few things relative to the Stardust vs Trapcode debate ... Trapcode looked more versatile. I am going to dig deeper into Stardust ...
But Trapcode TAO will be hard to beat for expression designed curves ...
Well, choosing the right tool is 30% of the job ... 40% ? ☺
Thanks • | **Re: 3D curves and surfaces mathematically defined** on Apr 5, 2019 at 3:53:17 pm |
No experience with generating 3D object with Python in Blender, but I suspect that Blender+Python is actually the better option, considering Blender is dedicatedly a 3D software while Processing is 2D and 3D and primarily concerned with rapidly generating interactive graphics by coding. The plus with processing is that it is Java-based, and very easy to learn. You can export as OBJ, but again, I haven't actually tried this as yet.
Creating things with Element is very limited, but rendering is incredibly fast and the quality quite decent.
Kalleheikki Kannisto
Senior Graphic Designer • | **Re: 3D curves and surfaces mathematically defined** on Apr 5, 2019 at 4:26:31 pm |
Drawing lines along mathematically generated curves can also be done fairly easily with Particular. You can emit from lights, the 3D positions of which can be controlled by expressions. To animate such, you will have to draw the complete shape within one frame with tens of thousands of particles and have the particles live for a duration of one frame.
But generating surfaces is a whole different matter, for which you will need the Blender+Python or Processing solution.
Kalleheikki Kannisto
Senior Graphic Designer
• | **Re: 3D curves and surfaces mathematically defined** on Apr 5, 2019 at 5:19:08 pm |
Thanks, Kalleheikki,
I see. This method with Particular seems interesting but Form and TAO also can do it right.
I think I will buy the Trapcode Suite. So versatile ...
I'll use Blender for surfaces and objects ... I used to work with it 14 years ago (!!) ... and Python is a good friend of mine too as my students learn programming with it.
It feels good to have a solution for these problems. ☺
Thanks for your help. • | **Re: 3D curves and surfaces mathematically defined** on Apr 5, 2019 at 5:35:50 pm Last Edited By Kalleheikki Kannisto on Apr 5, 2019 at 5:41:13 pm |
How do you want to render the surfaces? If you need solid surfaces, Trapcode may not be the best solution. Their particle systems will turn the OBJ surfaces into particle sources.
If you want to render solid objects and object sequences, look into Element and Stardust.
Although Tao may be able to do what you want -- depending on what it is that you're aiming at.
Kalleheikki Kannisto
Senior Graphic Designer • | **Re: 3D curves and surfaces mathematically defined** on Apr 5, 2019 at 9:08:00 pm |
I am of course not a Form user yet but I read a part of the documentation and there are more than one display option fo OBJs :
https://www.redgiant.com/user-guide/form/base-form-obj/
(at the end of the page ... see the horse.)
If I need something more physically realistic, I 'll go to 3D elements.
But what I don't understand is how stardust can help "render" OBJs ... it is a particule plugin, isn't it ? ... Maybe I should read the documentation ... 😃 ...
As my current limitation is what my brain can learn, it is also what my wallet can buy at the very beginning of this project.
So I have to choose my tools carefully. I can't *afford* everything ...
Thanks
• | **Re: 3D curves and surfaces mathematically defined** on Apr 6, 2019 at 7:00:59 am |
The main difference that I am pointing out here is that with Form and Particular, you can use OBJ files as particle *emitters* only, so any OBJ surfaces will be made out of particles, not solid fills.
With Element and Stardust you can also use OBJ files (and sequences) as *particles* (including displaying a single particle), which means you can render solid 3D objects like you would in any 3D software.
In my humble opinion, if you want the best return on investment, I would recommend Stardust. It has most of the features in the Trapcode Suite and Element 3D in one single integrated package. The main downside with Stardust is sparse documentation.
Kalleheikki Kannisto
Senior Graphic Designer • | **Re: 3D curves and surfaces mathematically defined** on Apr 6, 2019 at 12:35:13 pm |
I understand.
I am surprised though that Stardust can render OBJs so well. Good.
The connected boxes interface is great.
And Physics is amazing ... I would use it a lot ( for videos about probability for instance ).
It is cheap compared to Trapcode ...
One thing that is disappointing : 3D curves are defined by splines made out of lights .... and I really don't know how to go from my usual expression defined curves ( defined with : x(t) = ... ; y(t) = ... , z(t) = ... ) to a set of lights ... "indicating" the way ...
And if you remember, it was the initial goal of this post ... 😃
I will soon end up with Trapcode and Stardust ... these tools are amazing ...
Thanks ! • | **Re: 3D curves and surfaces mathematically defined** on Apr 6, 2019 at 3:43:23 pm |
**[Nicolas Guionnet]** *" I really don't know how to go from my usual expression defined curves ( defined with : x(t) = ... ; y(t) = ... , z(t) = ... ) to a set of lights ... "indicating" the way"*
It works the same way. You just use x(time), y(time), z(time) for the position of a single light. The position over time of each light becomes a separate path.
Kalleheikki Kannisto
Senior Graphic Designer
• | **Re: 3D curves and surfaces mathematically defined** on Apr 6, 2019 at 5:49:24 pm |
Thanks Kalleheikki,
I first thought : That's it ! ... then came another question :
How can you animate the path then ? ... as the time variable already defines the path ... and the problem is the same in Trapcode and Stardust ... • | **Re: 3D curves and surfaces mathematically defined** on Apr 6, 2019 at 6:13:16 pm |
You have to draw the entire shape in one frame, using particles with a life span of one frame and then draw the next stage of the shape in the next frame, etc.
Works just fine in Particular, where I've done it many a time. Haven't tried in Stardust, but should work the same.
Kalleheikki Kannisto
Senior Graphic Designer • | **Re: 3D curves and surfaces mathematically defined** on Apr 7, 2019 at 9:59:51 am |
> "You have to draw the entire shape in one frame"
Well, I don't really get it.
I could do it with a 2D shape (drawn in a layer with some simple expressions with a loop on createPath and depending on time). But I need a 3D curve ...
And everywhere I saw a 3D curve defined with a mathematical function it was this way : x(time), y(time), z(time) with time as variable ... and to animate it I would need this :
x( time , lamdda ) , y( time , lamdda ) , z( time , lamdda )
... where lamda is a parameter changing the curve ...
BUT ... to animate the curve I need to change lamdda : labda = lamdda(time) ... and I don't think it is possible to tell Trapcode or Stardust : "draw the curve acting as if lamdda was a constant." ... and animate lamda "under the table" hidden from Trapcode or Stardust ....
I begin to think that the only way to do this is outside of AE : Blender Script and then import the OBJ ... but what a pain in the ... hips ... to animate it and synchronize it with the audio ...
• | **Re: 3D curves and surfaces mathematically defined** on Apr 7, 2019 at 4:00:07 pm |
(Not being able to) **Animate a 3D curve with TAO**
I finally installed Trapcode trial and tried to use TAO to animate a 3d curve.
I used a light to draw my 3D-curve. In fact, it is a series of 3D Curves concatenated (tricky) ... that would be used for the animation.
I just needed to find a way to tell TAO to :
Draw only a part of the curve, the one for :
lambda < **time** < lambda + myComp.frame.duration
(... and then animate lambda.)
**It seems there is no way in TAO** . I could try to implement a kind of non-robust hacky floppy tricky workaround using ... size offset to reveal only the wanted part of my curve and animate it. But ... no
Let's try Stardust • | **Re: 3D curves and surfaces mathematically defined** on Apr 7, 2019 at 6:36:33 pm |
Can you give an example formula that you want to use? Would be easier to sort it out.
Kalleheikki Kannisto
Senior Graphic Designer • | **Re: 3D curves and surfaces mathematically defined** on Apr 7, 2019 at 9:06:40 pm |
I think I am going to try Particular, in the way you described up there. As you said, Stardust has no real documentation ...
An example formula ? A nice one :
x(t) = 100.exp ( - (t-5)² . lambda ) . cos (10*t)
y(t) = 100.exp ( - (t-5)² . lambda ) . sin (10*t)
z(t) = 20t
0 < t < 10
0 < lambda < 30
• | **Re: 3D curves and surfaces mathematically defined** on Apr 7, 2019 at 9:35:22 pm |
... and I forgot to say that lambda is the parameter to be animated. • | **Re: 3D curves and surfaces mathematically defined** on Apr 8, 2019 at 8:33:45 am |
Not sure if I'm interpreting this right, but here's what I got for the light position:
`fps = 1/thisComp.frameDuration;`
t = Math.floor(fps*time)/fps;
cur_frame = time*fps;
lambda = cur_frame%1*30;
x= 100*Math.exp(-(t-5)*(t-5)*lambda)*Math.cos(10*t);
y = 100*Math.exp(-(t-5)*(t-5)*lambda)*Math.sin(10*t);
z = 20*t;
[x,y,z]
With 30000 particles per second and a particle life of one frame, I get something that looks like this (a still from early in the animation). This shape unfurls along time.
Kalleheikki Kannisto
Senior Graphic Designer • | **Re: 3D curves and surfaces mathematically defined** on Apr 8, 2019 at 10:52:28 am |
Great ! Great ! !
It's such a relief for me to see it is finally possible.
You did it with particular, didn't you ?
I went to bed yesterday, really late, deducing from my failureS that it was not possible, which is really vain, for after 3 hours of work on a piece of software like Particular, you can't deduce much of its real possibilities.
Now, I am on my way to (try to) reproduce your success ...
Thank you so much Kalleheikki ... • | **Re: 3D curves and surfaces mathematically defined** on Apr 8, 2019 at 1:38:38 pm |
Yes, with Particular. There seems to be some limit, around 26000 particles, above which the figure doesn't really change, meaning you can't get the points closer to each other than this. But it may be possible to handle it by modifying the formula itself.
One important factor is to make sure that most of the velocity and emitter size related settings are at zero so that the particles don't start flying around.
Kalleheikki Kannisto
Senior Graphic Designer • | **Re: 3D curves and surfaces mathematically defined** on Apr 8, 2019 at 4:59:32 pm |
... strange, I don't get the whole curve. In fact, just a tiny piece of it.
I created a solid and applied Particular to it.
Particule life : thisComp.frameDuration
Part/sec : 30 000
Velocity and associated parameters : 0
Emitter size: 1
Emitter type : lights
I created a point light named Emitter.
I put you code in its Transform.position
I keep on searching ... I guess 4 hours is not enough to master Particular ...
13255_quantum3dwithparticularkalleheikki.aep.zip • | **Re: 3D curves and surfaces mathematically defined** on Apr 8, 2019 at 7:12:37 pm |
Position subframe should be set to "exact", that way Particular will calculate subframe particle positions accurately.
Kalleheikki Kannisto
Senior Graphic Designer • | **Re: 3D curves and surfaces mathematically defined** on Apr 9, 2019 at 12:10:48 am |
... time to go to bed before this thing drives me crazy ... I tried every option that could be connected with the problem, mainly in the Emitter group.
I get a tiny segment turning around ...
• | **Re: 3D curves and surfaces mathematically defined** on Apr 9, 2019 at 9:33:26 am |
Not sure what is different, so here's my project file you can investigate.
13257_lambda01.aep.zip
By the way, I'm pretty sure this isn't set up how it is supposed to be. I have lambda changing from 0 to 30 in each frame and time changing in steps along the timeline. But at least it gives a curve of some kind.
It should be possible to trace a surface over time if this was set up differently, i.e. t going from 0 to 10 each frame and lambda changing over time and having the particles persist, rather than last for just one frame.
Since I don't know how this is actually supposed to look, this is conjecture.
Kalleheikki Kannisto
Senior Graphic Designer • | **Re: 3D curves and surfaces mathematically defined** on Apr 9, 2019 at 2:08:05 pm |
Great,
In my code, there was an inversion between the 2 parameters. The valid code is below where ...
- T is the time passing and causing the animation and
- s is the parameter that draws the curve.
The result is very promising.
One thing though :
I couldn't increase the number of dots.
Increasing the number of particles did nothing but superpose the old ones with new ones ... It is as if there was a limitation in time definition.
Is it the case ? ... I wonder if it can be changed.
Thanks a lot ... This is going to be useful.
`fps = 1/thisComp.frameDuration;`
cur_frame = time*fps;
T = Math.floor(fps*time)/fps/100;
s = cur_frame%1*10;
x= 100*Math.exp(-(s-5)*(s-5)*T)*Math.cos(20.01*s+T*450);
y = 100*Math.exp(-(s-5)*(s-5)*T)*Math.sin(20.01*s+T*450);
z = 50*s-150;
[x,y,z] • | **Re: 3D curves and surfaces mathematically defined** on Apr 10, 2019 at 4:27:04 am |
**[Nicolas Guionnet]** *"I couldn't increase the number of dots."*
Same here. It could be the Math.floor statement. I thought I had some logical reason to put it in, but maybe it is unnecessary. You can try it without.
Or then it is a limitation in math accuracy, considering all points are getting drawn in within a single frame. In which case the formula itself will need to be modified, or possibly the frame rate decreased to allow for more accurate calculation. You could make it 1 fps, output as frames, and import as footage into a new comp.
Kalleheikki Kannisto
Senior Graphic Designer
• | **Re: 3D curves and surfaces mathematically defined** on Apr 10, 2019 at 8:28:11 am |
Right !
4 fps :
2 fps :
... and there we see, finally, the particle moving in its quantum wave. Nice.
I would be surprised if it was the math accuracy considering the number of digits delivered by AE when I display a value in a Text Layer.
But these days, I am surprised 10 times a day ...
Now i try to evaluate the **[** output as frames, and import as footage into a new comp **]** process in term of feasibility.
Tweaking the code could be another option ...
Thanks • | **Re: 3D curves and surfaces mathematically defined** on Apr 11, 2019 at 7:27:27 am |
Goody -- that did it. Looking very nice.
(Did you also try removing the Math.floor from the expression?)
Next step might be making the particles persist longer, which would -- if the formula is suitable -- create surfaces over time.
Kalleheikki Kannisto
Senior Graphic Designer • | **Re: 3D curves and surfaces mathematically defined** on Apr 11, 2019 at 3:17:34 pm |
Well, removing Math.floor() had no effect.
But choosing 4fps and even more with2 fps increased dramatically render time.
Increasing, particle life produces indeed a surface. But it seems hard to control.
And to get more control, I am on my way to use Blender script to produce OBJs and import theme into Trapcode or Stardust ...
• | **Re: 3D curves and surfaces mathematically defined** on Apr 12, 2019 at 8:04:55 am |
Cool. Will be most interested in seeing the outcome from that method as well.
Kalleheikki Kannisto
Senior Graphic Designer
| |