Set Curve Tangent

when i create an interpolated curve i have the option to set a directional start and end tangent. but once a curve is created i dont seem to have any options anymore other than creating two perpendicular curves (yellow curves in the picture below) and matching the ends of my curve towards them.

for surfaces we have SetSurfaceTangent which does exactly that. is there an anything equivalent for curves which i missed or is match the only option?

23

PointsOn will display the control points, the 2 points nearest to the end will set the end or start tangent (at least on a degree=3, did not check other degrees). I use Rotate with the end point as origin and the next point as target to change the tangent.

Max.

1 Like

thats of course an option, probably faster than match, but having to rebuild the curve first and then adjusting the points manually is also not very convenient. especially having a tone of those lines to bend a SetCrvTangent would be helpful, @pascal any thoughts?

Give HBar a try, with Ortho on it provides an easy way of creating an orthogonal tangent and control the end bulge at the same time.

1 Like

cool, i was looking for that command, i knew its possible but never used it and was looking for something with Handle and never found it, thanks!

I never used it, I only started looking for something because of your question. I learned something new, cool forum interaction i’d say!

Max.

Hi Richard, Max - my thought so far for a workflow would be to set a direction and then click-click-click on the ends of the curves to set, possibly with an option to change the direction vector on the command line so you could stay in the command to do say, both ends of a set of curves. Does this seem reasonable?

Here’s a first go at this, in py form… use _RunPythonScript or -_RunPythonScript "Full path to py file inside double quotes" to give it a spin.

@RichardZ. @maxz, if you tell me this one works, I think I’m done for now, this one seems practically useful - you get to use another curve’s tangent to set the current tangent direction.
SetCurveTangent.py (4.6 KB)

Plug-inized:
SetCurveTangent.rhp (12.5 KB)

-Pascal

1 Like

Hi Pascal, this is a function fulfilling a need I was not even aware of :smile:. But it seems to work ok and it could come in handy one day. The trick is (at my age) to remember it when that day comes.:roll_eyes:
The prompts for the tangent direction are a bit sparse, “Pick a point” should be something like “Pick a base point for tangent direction” and "Pick the direction end point"
A little niggle/preference: when you start out picking a base point for a direction, then change your mind and select one of the matching-options, your latest cursor position is registered as the direction point and the matching-option is ignored. I would prefer to see the direction being abandoned and the matching option given preference.

Max.

thats a very nice surprise Pascal thanks a lot, i think thats a useful plugin/script and works speedy enough for a bunch of such curves. they still have some hick ups though:

• escaping the py script before i do anything or after using match i get an exception error but it works after i select the direction. the plugin does not mind early escapes.

• when i pick a curve which has a corrected tangent already the script burps up an exception, the plugin just quits and leaves me with the otherwise very fancy direction arrow

something important still:

it changes the curve pretty strong, see picture below. using a degree 2 curve with 3 points is logically out of the question, so i rebuild it to degree 3 the match command does that automatically. but either way using the match command or your plugin/script it lifts the middle point up. the green curve indicates how it “should” be, achieved here through scaling the ControlPolygon Points in 1D to the boarders while the dashed green line was created through blend which results in a better continuity. but probably i am asking too much now, i believe that would need some deeper digging.

@maxz thats how i learned many things here either, good motivation for sure, this time i was probably too dumb and/or too lazy :smiley:

yup the very first py script which is now replaced had “set tangent direction base point”, “pick point” is a bit too abstract i think.

Hi Richard - yeah, that is a different problem - the tangent setter keeps the end point-to-tangent-point distance the same - like Match it makes no claim that it will make a curve you like, it only sets the tangent direction.

-Pascal

I lied - it does not. But it should, I’ll see if I can fix it. Ah. It looks like it does not if the tangent cv weight is not 1.

Fixed - SetCurveTangent.zip (10.0 KB)

-Pascal

looks good now, no hick ups which i could find, thanks again for the effort!! i hope others will find this useful either. i would send you a bottle or two of tasty austrian beer, but it seems the delivery costs would be almost 20 times more than the beer itself :scream: but if you are eager to try some i could consider doing that anyway if you toss me an address where i can send it to :smiley:

they all are set to 1, but they still jump. at least here on the mac version, below a little video with a degree 2 with 3 points which of course will not result symmetrically but shows how it keeps growing after each time clicking. if i add more points something like 7 or 8 points the height gets kinda controllable but the continuity does not look nice. it gets very wavy, i guess there is no chance changing this without implementing a geometric hack?

@pascal: Looks good to me, except for the niggle I had before about changing your mind halfway.

I am not seeing what Richard shows in his video on a degree 3 curve, which I use most of the time anyway (my ignorance?).

Max.

Hi Richard - I guess that is expected on a three-point curve - the distance between the end you pick and the middle point will grow as you swap back and forth.

-Pascal

on a degree 3 curve it of course grows only once but if this is expected then i dont understand why it would jump up at all. if it would move the CVs aside instead of pushing them up it would fulfill its purpose even better, also the continuity of the curve could be handled 1dimensionally.

but anyway i keep playing with this for a while now and i actually cant stop playing with it. i wonder why its not implemented into vanilla rhino. i mean having a set surface tangent is sure more helpful considering the amount of points but also for curves this is an important tool i think.

Hi Richard - it could move the point to the closest point on the new direction line - that might be good in some cases but my guess is that in many - depending on just what the difference in the vector is - it might just be a different kind of wrong - your middle point problem would be solved for jumping back and forth between ends ( a corner case not really applicable in real life, I would say) , but repeated applications with different vectors would shorten the distance or grow it as well. It seems ‘safer’ and more predictable to me not to change the end-point-to-tangent-point distance at all for the general case. I’ll fuss with the ‘closest point’ version if I find some time later.

-Pascal

yes i was thinking that this may be situational, but i could not come up with an instance. also SetSurfaceTangent lifts up the tangential CVs, so i guess that is either generally wrong, or it is generally thought over and i dont understand it :smiley:

if you want to give it another thought or work the plugin further:
i have found that the symmetry tool set to smooth sets both, surface and curve tangential with a perfect continuity without altering its height only moving the CV to the tangent. its not as fast and elegant as your plugin and one has to delete the copied surfaces/curves but at least its an option. maybe if you want to proceed this you could look how its made in that command or implement a part of it. if your plugin could also address surfaces it would combine curves and surfaces and replace SetSurfaceTangent in my opinion.

Hi Richard - the closest point mode does have some ‘issues’ in many cases, as we predicted. You can play with Mode=ConstantDistace/ClosestPoint in this py - there are no doubt some bugs, as the typing is becoming a little convoluted wedging in new options in a way that - I hope- makes some sense.

Also, just fyi, ClosestPoint is not necessarily the actual closest point - if the actual closest point would cause the curve tangent to be opposite the one the user sets (which can easily happen) then the closest point distance is used but the point is put on the other side of the end point to conform to the desired tangent direction, if you see what I mean - I don’t know how else to handle that case and have the direction settings mean anything.

SetCurveTangent_EX.py (6.8 KB)

-Pascal

1 Like

by trying to understand what kind off issue you are talking about with the closest point i found the following -> see image and file: when the closest CV is aligned exactly perpendicular to the new tangent direction, the closest points option merges the CV into the endpoint “ignoring” the direction. so it would have to find the next point which has a negative direction from the endpoint towards the tangent then it would work again i believe. or having it switch automatically to constant distance in such cases and obsoleting the manual setting?

issue.3dm (34.9 KB)

the script works to my experience without hick ups, will you make a plugin still? and do you think it would be possible to combine it with surfaces and make an overall SetTangent command? or way too much work? maybe as an idea for the future.

Hi Richard - Right, this is the extreme case of the problem but it is weird and bad, I would say, even at a less than 90 degree angle, which is why I used the constant distance initially. I’ll see if I can make it auto-switch at some tolerance.

-Pascal