Copy link to clipboard
Copied
I'm trying to make a spiral out of a catwalk element.
I'm trying to figure out if there's a way to do this with expressions.
I made a chain, using
pos=thisComp.layer(index-1).position; [pos[0]+2700,pos[1],pos[2]]
then manually added 20 degrees of y rotation working backwards from the end to the start.
then I parented the layers from the end to the start, and then adjusted the orientation of the start element.
I think what I want is some kind of expression that
1) moves the layer into position at the end of the chain
2) rotates it
So is there a way to craft an expression for step 1 than slides the layer into position along the RELATIVE x axis? i.e given that I want my spiral to rise?
thanks!
John
You would have to convert the coordinates and rotations with toWorld() and toWorldVec() and then calculate the next position. For a helix it may generally be simpler to just use cosine and sine functions and multiply the angles linearly based on index. Could be something like this for the positions:
mSeg=thisComp.layer("Controller").effect("Segments per Round")("Slider");
mInc=thisComp.layer("Controller").effect("Increment per Segment")("Slider");
mRad=thisComp.layer("Controller").effect("Radi
...Copy link to clipboard
Copied
You would have to convert the coordinates and rotations with toWorld() and toWorldVec() and then calculate the next position. For a helix it may generally be simpler to just use cosine and sine functions and multiply the angles linearly based on index. Could be something like this for the positions:
mSeg=thisComp.layer("Controller").effect("Segments per Round")("Slider");
mInc=thisComp.layer("Controller").effect("Increment per Segment")("Slider");
mRad=thisComp.layer("Controller").effect("Radius")("Slider");
mAng=Math.PI*2%mSeg;
mCen=this comp.layer("Center").transform.position;
X=mCen[0]+Math.cos(mAng)*mRad;
Y=mInc*index-1;
Z=mCen[2]+Math.sin(mAng)*mRad;
[X,Y,Z]
For the rotation you would use the same approach like with that Y position - multiply a fixed value by index. Of course you need to create the controller with the sliders, the center Null and all that.
Mylenium
Copy link to clipboard
Copied
Thanks
That may be beyond my pay grade unfortunately... but I'm going to try it...
In the meantime I tried to brute force it. I can sort of see where the trigonometry comes in as I had to calculate my x and y displacements after positioning the first one manually...
The best I have come up with is to have an original 'neutral' element
duplicate it
orient it along z 20 degrees (so my catwalks go 'up')
slide it along x
raise it along y
then rotate on y so it curves inwards
then repeat with the added step of parenting the previous layers to the 'new' one after I duplicated it and oriented it...
but I'm off to learn how to set up sliders and controllers! Thanks!
Copy link to clipboard
Copied
I got part of the way. At least far enough that the expression didn't have syntax errors...
I've attached the sequence if you have time to look -- the catwalks are basically just rectangular prisms.
I didn't try the rotation - probably why my catwalks just 'stacked'
thanks again
Copy link to clipboard
Copied
I may be able to set up a demo project tomorrow when I'm back at the computer. On my tablet currently. 🙂
Mylenium
Copy link to clipboard
Copied
Thanks again!
It looks like a VERY elegant approach...that I don't quite understand all the pieces of.
All the best
John
Copy link to clipboard
Copied
Here's a project I hacked together. It should at least give you a grasp of some basics. As usual it could be infinitely refined and adapted to your specific needs and I would try to make it a bit more elegant by auto-calculating the angles and scaling the segments to fit without gaps. Maybe if I have a lazy evening and feel like it.
Mylenium
Copy link to clipboard
Copied
Maestro!
I'm going to pore over it to see if I can make sense of it - already I was able to semi brute force a result by making a controller with sliders for each segments rotation...while I was still doing the initial position manually, it let me play with the pitch yaw and roll until I got a semi passable result.
But your project is far more interesting...
thanks!
Copy link to clipboard
Copied
That made me look up how cosine works...which funnily enough has been a semi-goal for awhile "relearn high school math"... oh the rabbit holes these expressions open up!