I've been working on python Curve Deformation tool. I need some help with the math. Possibly someone can help here. I cannot find correct UpVec for my custom curve.

Here are the screens which explain the problem:

enter image description here enter image description here

Here is my tool in action: https://youtu.be/Nxu6-0xm3Io

Here is the code I did but it's buggy in some angles. It inverts to 180 degrees on some angles: https://github.com/mifth/mifthtools/blob/96e73eb3a2613b3f1396ddd7c4bdd9d0419ca5e3/blender/addons/mira_tools/mi_curve_guide.py#L515-L537

All I do is just cross direction of the point to global X and Y axis. Any help will be appreciated to get the quality of upVec as in Blender Curves.

And you can get the tool here: https://github.com/mifth/mifthtools http://blenderartists.org/forum/showthread.php?366107-MiraTools


  • $\begingroup$ perhaps an intereting read: rollercoasters-and-normals by freek hoekstra. (a blog post about exactly this problem) $\endgroup$ – zeffii May 8 '15 at 10:42
  • 1
    $\begingroup$ Do you want to find the tilt as shown in the viewport? or calculate it from your own bezier data? $\endgroup$ – ideasman42 May 8 '15 at 10:46
  • 1
    $\begingroup$ ideasman42 - i need the same tilt for my custom python curve. Here is "deform_lines" array of all points of the curve and all their directions. github.com/mifth/mifthtools/blob/… $\endgroup$ – mifth May 8 '15 at 11:09

There are 3 ways for upVec to be found:

2 and 3 versions were suggested by mano-wii from here http://blenderartists.org/forum/showthread.php?361154-Coordinates-of-resolution-points-of-a-Bezier-Curve

1) Cross vec. https://github.com/mifth/mifthtools/blob/6b0469faea18d3375c3f3257963d7c85f327c44c/blender/addons/mira_tools/mi_curve_guide.py#L486-L488

2) Project vec. http://blenderartists.org/forum/showthread.php?361154-Coordinates-of-resolution-points-of-a-Bezier-Curve&p=2866256&viewfull=1#post2866256 https://github.com/mifth/mifthtools/blob/6b0469faea18d3375c3f3257963d7c85f327c44c/blender/addons/mira_tools/mi_curve_guide.py#L490-L492

3) Dot vec. http://blenderartists.org/forum/showthread.php?361154-Coordinates-of-resolution-points-of-a-Bezier-Curve&p=2866427&viewfull=1#post2866427 https://github.com/mifth/mifthtools/blob/6b0469faea18d3375c3f3257963d7c85f327c44c/blender/addons/mira_tools/mi_curve_guide.py#L494-L497

I choosed Cross vec for my approach for the upVec searching. You can comment/uncomment any of approaches and try testing.

Also,I found another issue: One direction can has different upVecs. http://i.imgur.com/itANWG6.png

To fix this issue I have to pick first point upVec and then check all points after. If a current upVecAngle is more than 90 degrees - we need to invert upVec. Here is the code to fix this issue: https://github.com/mifth/mifthtools/blob/6b0469faea18d3375c3f3257963d7c85f327c44c/blender/addons/mira_tools/mi_curve_guide.py#L504-L509

And you can see the result of my custom curve in editmode here: https://www.youtube.com/watch?v=VXWSUwOul-s

  • 2
    $\begingroup$ Please avoid link-only answers. All main information in your answer should be available without having to link anywhere else. Besides being a nice format, if a link goes down then so does your answer. $\endgroup$ – PGmath Sep 3 '16 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.