3
$\begingroup$

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

Thanks.

$\endgroup$
3
  • $\begingroup$ perhaps an intereting read: rollercoasters-and-normals by freek hoekstra. (a blog post about exactly this problem) $\endgroup$
    – zeffii
    Commented May 8, 2015 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
    Commented May 8, 2015 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
    Commented May 8, 2015 at 11:09

1 Answer 1

2
$\begingroup$

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. https://i.sstatic.net/WBhG3.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

$\endgroup$
1
  • 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
    Commented Sep 3, 2016 at 23:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .