Page 1 of 1

Curve interpolation algorithm

Posted: Sun Aug 11, 2024 1:47 am
by morevnaproject
Hi everyone!
I am writing a python script to convert from Moho format to other vector software.
The script is already capable to extract points and convert simple shapes.
But I cannot figure out how Moho interpolates curve between points. Is there any documentation for this algorithm available?
Thanks in advance!

Re: Curve interpolation algorithm

Posted: Sun Aug 11, 2024 4:00 am
by synthsin75
If memory serves, I believe it's cubic beziers, defined by 4 points.

Hayasidist knows all about that. Hopefully he chimes in.

Re: Curve interpolation algorithm

Posted: Sun Aug 11, 2024 5:10 am
by hayasidist
yeah cubic bezier. Assuming you know what that is:

the actual Moho points are P0 and P3. You then need to derive P1 and P2 from the way Moho stores the "curvature" -- see https://mohoscripting.com/snippets/5

Re: Curve interpolation algorithm

Posted: Sun Aug 11, 2024 8:18 am
by SimplSam
Also note: If you are reading the Moho JSON data - in some cases you may not get the true position of the points - if they are influenced by Bones, Actions, Smart Actions, Physics, Meshes or Curvers.

Re: Curve interpolation algorithm

Posted: Mon Aug 12, 2024 1:48 am
by morevnaproject
Awesome! Thank you so much for responding, everyone!
The information you provided helps a lot!

Re: Curve interpolation algorithm

Posted: Sun Oct 12, 2025 12:05 am
by morevnaproject
hayasidist wrote: Sun Aug 11, 2024 5:10 am yeah cubic bezier. Assuming you know what that is:

the actual Moho points are P0 and P3. You then need to derive P1 and P2 from the way Moho stores the "curvature" -- see https://mohoscripting.com/snippets/5
Hi! I have made tests and the script you referenced and found that it doesn't give correct results: coordinates of P1 and P2 are not calculated correctly.
It is easy to check just by comparing its results with output of GetControlHandle() function.

So, are there any other information available how to find coordinates of P1 and P2?
Will much appreciate any hint!

Re: Curve interpolation algorithm

Posted: Sun Oct 12, 2025 8:22 am
by hayasidist
odd -- the script writer (Alexandra) who created that snippet (back in 2017) rarely gets things badly wrong and has likely used that code in her scripts. Can you please check that you're calling it and GetControlHandle consistently. Also note that GetControlHandle returns the handle absolute position after applying all smartbones (IOW, in some circumstances a difference is expected!)

If you're still convinced that it is an error in the algorithm, then can you please upload the code (and, if necessary, the moho file) that shows the error so someone can take a deeper look!