Author Topic: PolyClean v 1.0 - Round the coord of a PolyLine to a given number of decimals  (Read 26963 times)

Offline onekk

  • CNC Jedi
  • *****
  • Posts: 525
    • View Profile
News: In Polyround-v1_1.zip you will find a new version of the source code with a different name and a different menu item "Poly Round" to be more clear on what the plugin does.

Thanks to EddyCurrent for the dll compiled for windows,


Hi to all, it maybe useful for someone.

Critics  are welcome, but only inherent the source code. :-D

Credits are on the Readme file and in the zip.

Regards to all

Carlo D.
« Last Edit: January 16, 2016, 10:06:36 am by onekk »
Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5334
  • Made in England
    • View Profile
Carlo,

I've just noticed it does not round the Bulge numbers, is that how you wanted it ?
Also,  public int PolyClean(Polyline p) is always going to return 1
Filmed in Supermarionation

Offline onekk

  • CNC Jedi
  • *****
  • Posts: 525
    • View Profile
Hi Eddy,

Bulge is the parameter of the curvature of the segment, so i don't round it, more decimals here is better, so you can curve it more smoothly. (I'm curios to know the geometrical meaning of the bulge parameters).

The Linux interface show you only the integer part when the decimals are more than 5 or 6 and you are sure that everything is ok, but if you try to change the values you see all those decimals, and if you rely on what you see at a first glance and draw a point with the "integer" coordinates you have a polyline that is not closed or "closeable" due to the mismatch of the points.
 
This is the main goal of my plugin.

I wonder why CamBam retains so much decimals, (or better why it didn't have an option to specify a rounding precision) maybe using 1 meter as units, but after all this precision is used in drawing when you machine you can use only G20 and G21 (inch and mm) so the 0,0000001 mm or even inches I think is out of reach of the majority of the actual CNC machines.

The routine return always 1, in fact future development may return a different number to tell that a some points where changed, but for now it return 1 because I'm not a to skilled programmer in C#, and during the test i copied a routine with an int return value and leave it in place.  I hope that it isn't too bad.

Regards and again many thanks for your invaluable help.

Carlo D. 
Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5334
  • Made in England
    • View Profile
I hope that it isn't too bad.
Carlo D. 

Carlo, whatever you do in your own code is your choice and that is good, the return value was just something I saw and like all of us, something you might have missed.

Filmed in Supermarionation

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7614
    • View Profile
    • Cambam V1.0 French Doc
Hello,

Quote
I wonder why CamBam retains so much decimals, (or better why it didn't have an option to specify a rounding precision) maybe using 1 meter as units, but after all this precision is used in drawing when you machine you can use only G20 and G21 (inch and mm) so the 0,0000001 mm or even inches I think is out of reach of the majority of the actual CNC machines.

I assume it's because if you move the polyline several time (without grid snap ON), and if you round the coordinate after each move, you lose precision. (same thing for matrix transformation)

++
David

Offline onekk

  • CNC Jedi
  • *****
  • Posts: 525
    • View Profile
Quote
Carlo, whatever you do in your own code is your choice and that is good, the return value was just something I saw and like all of us, something you might have missed.

In fact I have missed many things in the code, I missed to change the name of some variables that belongs to your code, from what I stolen some code. :-D

Now I'm working to a more polished code, with some comments and some more meaningful names. When I have done that I will ask you if you could compile my source for Windows as you kindly have done with version 1.0.

David.

Quote
I assume it's because if you move the polyline several time (without grid snap ON), and if you round the coordinate after each move, you lose precision. (same thing for matrix transformation)

For linear move I think that the error is not so great, if your choice is to not use "snap to grid", you lose all precision move, pixel to "real coordinates" are ever and interpolation.

For matrix trasformation, is even worse, if you rotate a rectangle, the "exact" coordinates are never preserved say if you have a 30x40mm  rectangle you will have after a rotate matrix trasformation a 30.000000000005x40.00000000003 (some number similar to those) rectangle.

That could be avoided if use a concept similar to the "decimal" type of some language instead of the "double float" that is used actually, i didn't know if there is a "decimal" implementation for .NET, and what amount of rewriting is needed, but in a CAD program the approximation has to be controlled in some manner, but speakly mathematics, "The exact science is permeated with the concept of epsilon and limits, all of these are only approximation, but you know the amoount of that approximation".

Even CNC is an approximation, you state to machine a square of 30x30 and obtain a 30x30 squre +-0.00000whatever is the precision of your machine.

But this is too much philosophical.

Take this post as an appreciation for your help.

For 100Euro or so CamBam is the most price per value software I ever bought, it make things and not only "smoke". (If you set the spindle speed correctly for your material and there is enough  cooling ) ;-D

Regards to all

Carlo D.
 
Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7614
    • View Profile
    • Cambam V1.0 French Doc
Re

Quote
When I have done that I will ask you if you could compile my source for Windows as you kindly have done with version 1.0.

I use the .dll you provide in the first message, and it works as is on Windows !! .. no need to recompile ...

++
David

Offline onekk

  • CNC Jedi
  • *****
  • Posts: 525
    • View Profile
David the .dll I provided was gently sent to me by EddyCurrent that compiled my code on Windows.

In the first post I will attach the version 1.1 with the name changed, as it it more tight to what the routine does.

Regards

Carlo D.
Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7614
    • View Profile
    • Cambam V1.0 French Doc
Ah sorry, I misunderstood !  :-[

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5334
  • Made in England
    • View Profile
Carlo,

Compiled dll attached
Filmed in Supermarionation

Offline onekk

  • CNC Jedi
  • *****
  • Posts: 525
    • View Profile
Thank you Eddy.

Carlo D.
Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7614
    • View Profile
    • Cambam V1.0 French Doc

Offline onekk

  • CNC Jedi
  • *****
  • Posts: 525
    • View Profile
Thanks, I'm reworking my shed so I haven't many time lefto on working on CamBam , hi to all the kind people on this forum.

Regards
Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam

Offline kvom

  • CNC Jedi
  • *****
  • Posts: 1614
    • View Profile

Offline onekk

  • CNC Jedi
  • *****
  • Posts: 525
    • View Profile
Many thanks, very interesting.

Regards
Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam