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!
			
			
									
									
						Curve interpolation algorithm
Moderators: Víctor Paredes, Belgarath, slowtiger
- 
				morevnaproject
 - Posts: 3
 - Joined: Sun May 26, 2024 12:17 am
 
- synthsin75
 - Posts: 10362
 - Joined: Mon Jan 14, 2008 2:20 pm
 - Location: Oklahoma
 - Contact:
 
Re: Curve interpolation algorithm
If memory serves, I believe it's cubic beziers, defined by 4 points. 
Hayasidist knows all about that. Hopefully he chimes in.
			
			
									
									Hayasidist knows all about that. Hopefully he chimes in.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
						Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
- hayasidist
 - Posts: 3907
 - Joined: Wed Feb 16, 2011 11:12 am
 - Location: Kent, England
 
Re: Curve interpolation algorithm
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
			
			
									
									
						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
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.
			
			
									
									Moho 14.3 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB 
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
						Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
- 
				morevnaproject
 - Posts: 3
 - Joined: Sun May 26, 2024 12:17 am
 
Re: Curve interpolation algorithm
Awesome! Thank you so much for responding, everyone! 
The information you provided helps a lot!
			
			
									
									
						The information you provided helps a lot!
- 
				morevnaproject
 - Posts: 3
 - Joined: Sun May 26, 2024 12:17 am
 
Re: Curve interpolation algorithm
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.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
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!
- hayasidist
 - Posts: 3907
 - Joined: Wed Feb 16, 2011 11:12 am
 - Location: Kent, England
 
Re: Curve interpolation algorithm
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!
			
			
									
									
						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!