domoszlai / juicy-gcode

A lightweight SVG to GCode converter for maximal curve fitting
https://hackage.haskell.org/package/juicy-gcode
MIT License
110 stars 7 forks source link

Is it possible to remove the transformations? #21

Closed asdf23 closed 1 year ago

asdf23 commented 1 year ago

I'd like to use this program without flipping the Y axis and without changing the X axis. My SVG file's points are in the same units as my plotter..

<svg>
<path d="M10,10 L 25,25"

I want to send to the plotter

G01 X10 Y10
G01 X25 y25

I believe the dpi setting is throwing off my X axis I can't pass a float (25.4) as a parameter. Also the Y axis is flipped upside down.

I'm hoping that you could provide (or help me to add a --as-is parameter so as to not adjust the points prior to plotting them.

I found your program trying to find a way to convert a bezier curve into a series of G2 and G3 (arcs) I have not found a way to do this.

Thanks

domoszlai commented 1 year ago

In theory we could add a flag, but it does not feel good tbh. These transformations implement the correct SVG semantics, your SVG is non standard 😉 How did you end up with this SVG? Also, would it no be easier for you to produce in a natural way?

asdf23 commented 1 year ago

Thank you for the response. Actually where I'm stuck in my own effort is to convert a bezier curve to a series of arcs (the plotter tool speaks G2 & G3 but not G5). I found some python code buried in inkscape and also you're program. I'm writing this all in node but really this is more of a math/how-to question. If you are interested, I'm writing a tool for a children's school that will help users to "write" with software. There's a ton of unusual customizations throughout this process. I was able to change your code removing the Y transformation and changing the dpi from 2.45 to a hard-coded 1. I'm still getting slightly different numbers out (not sure why) but I think I can adjust for this. -- I'll close the ticket. Thanks

domoszlai commented 1 year ago

I see. Have you seen this? https://github.com/domoszlai/bezier2biarc The bezier to G2/G3 conversion is pretty hard, this was a POC much easier to understand, also there is some visualisation Also, a brief explanation of the algorthm: https://dlacko.org/blog/2016/10/19/approximating-bezier-curves-by-biarcs/