correct scaling for in/out tangents in a maskrelated script•
Hello, i'm writing my first script, which is intended to draw various types of spiralshaped pathes on a mask. It's working fine, until i try to implement custom tangents: the direction is ok but the length is really puzzling me and i don't know how to normalize them. Let's say the ideal (continuous) path has coordinates (X(u), Y(u)), the parameter u running from 0 to infinity. The script takes a finite number of points in that curve and set them as vertices of the path. Setting only the vertices gives a linearbypart path, and to mimic the ideal curve one has to implement the tangents. The in and out tangents at point (X(u),Y(u)) are both proportionnal to (X'(u),Y'(u)) (the derivative of the position) but i can't figure out what is the scale to use. I have tested lots of things and apparently it depends on how far are the next and previous vertices in the path. Someone knows how it works ?
•
I haven't worked out the math for a spiral, but if you look at the way that Illustrator creates them, it appears to put all the vertices on two lines that are at right angles to each other. Adjacent tangents also seem to be at right angles to each other with the handles at some fixed percentage (looks like about 57%) of the distance from the vertex to the corner of the right angle. It seems like you should be able to work it out from there. Dan
•
Thank you for the answer, but it doesnt solve my problem. The script, as i plan it, should be able to handle an arbitray number of vertices per cycle, or even have them in random distribution (so when rotobezier is off it looks like a regular or irregular spider net.), and also be able to play with tangents orientation and length. But for I this should know what are the smoothest values for the tangents (the ones that reproduce the most the original curve). I tried to have them autocalculated by AE like this: myMask.rotoBezier = true; myPath.vertices = V_Array; //the array of vertices myPath.rotoBezier = true; myMaskPath.setValue(myPath); it returns no error but doesnt work, the mask is a concatenation of segments... I'd love to know the correct syntax !
•
I think it won't work unless you give it some tangents. This seems to work:
Dan
•
Thank you, this indeed turns rotobezier ON. However rotobezier gives poor result unless one inputs some already good enough values for the tangents. In case someone faces the same problem in the future, I post below a short script based on some doc on Bezier interpolation found there: http://people.sc.fsu.edu/~jburkardt/html/bezier_interpolation.html. (sorry, can't figure out how the link tool is working !) This script assumes that what AE calls Bezier interpolation is really a Bezier interpolation (there are many other types of interpolations similar to Bézier). But it works very well so it should be the case, and the algorythm will vectorize properly most curves (smooth enough, curves with sharp variation like sin with very high frenquency require more vertices). It creates 3 times more points than the number of vertices of the path (2/3 of these points are here to make sure that the path will walk through them). The funny numbers have their explanation in the doc linked above. Note: this is just the bit of code needed to get the Vertex and Tangents arrays. The script won't run as it is. To run it, one has to complete the input and add lines like: var myLayer = app.project.activeItem.layer(1); var myMask = myLayer.Masks.addProperty("ADBE Mask Atom"); myProperty = myMask.property("ADBE Mask Shape"); myPath = myProperty.value; myPath.vertices = V_Array; myPath.inTangents = IT_Array; myPath.outTangents = OT_Array; myPath.closed = CloseBoolean; myProperty.setValue(myPath); myMask.rotoBezier = rotoBezierBoolean; (etc.) function CurvePoint(u) { // the curve function
•
hi i tried placing values in you script but couldnt get it to work. can you give me an example start to finish how would it look completed for me to just change the mask points i want it to apply to?
