[Code] Versine and 3d arc-facets
-
A 'Versine' is the posh trig word for the difference between the radius of an Arc and the actual perpendicular distance measured to a 'segment', as used by SketchUp when approximating that Arc's perimeter.
SketchUp visually 'smooths' surfaces extruded from an Arc, so a modest segmentation number - like the default of 24 for a Circle - will usually look fine for most objects, and this level does not adversely affect modeling or rendering performance.
However, when 3d-printing the faceted appearance of a 'real' surface with only this level of segmentation might be unacceptable.
The more segments there are in the Arc, the smaller the 'Versine' distance and the smoother the surface appears, both visually to the touch.
So a 'Versine of ~1/1000" [0.001] is generally acceptable.
This also happens to be SketchUp's built-in tolerance for any line's start/end points to be deemed coincident, so smaller values are not a good idea.
Anything smaller 'Versine' is unlikely to be detectable in most forms.
This dimension can in turn be used to calculate the number of segments needed in a given Arc to achieve this level.
The smaller the Arc's radius, the lower the segment count needs to be for a given 'Versine'.The code below can be copy+pasted into the Ruby Console + <enter>.
In the dialog it asks for the Rad[ius], Tol.[aka 'Versine'] and [Swept-]Ang[le]°.
It does some trig...
It prints out those entered values, and the minimum Number of Segments need to achieve the given 'Versine', it also shows the '%4' value - i.e. the minimum Number of segments rounded up to be divisible by 4 - e.g. 70 >> 72 - this is because often it's easier to move/rotate and generally work with circles etc that have a segmentation which is divisible by 4 - it also reports the length of a segment, and if it is >=1/1000" - as any smaller sizes would fail to make facets etc when extruded.
Obviously a Circle sweeps 360°, but it works of Arcs proportionately to the Swept Angle entered otherwise.
The smallest Arcs you are likely to want to 3d-print are not going to get as small as tiny fractions of an inch [Num~=8], or more than say 12" radius [Num~=244].
But using this tool allows you to make educated assumptions about Arc/Circle segmentation based on their radii.Remember that you must set any Circle or Arc's segmentation when it is still a 2d object.
Once it is extruded into a surface making a 3d form you cannot change it [unless you use a 3rd-party 'SubD' tool - but then you'll have less control over the underlying geometry etc]I have made two versions of the one-liner code.
This first one uses inches:r=1.0;v=0.001;a=360.0;res=inputbox(["Rad.","Tol,","Ang.° "],[r,v,a],"Versine");if res;r,v,a=res;n=(0.5*a.degrees/Math.acos(r/(r+v))).round;m=n;m+=1 until m%4==0;b=0.5*a/m;s=2.0*r*Math.sin(b.degrees);puts"Rad.=#{r}, Tol.=#{v}, Ang.=#{a}°, Num.Segs=#{n}, %4=#{m}, Seg.Len.=#{s}>=0.001\"=#{s>=0.001}";end;
The default Radius is 1.0" [does not accept fractional input] and the Tol=0.001". The default Angle is 360° for a circle.
This second one uses mm:r=25.0;v=0.0254;a=360.0;res=inputbox(["Rad.","Tol,","Ang.° "],[r,v,a],"Versine[mm]");if res;r,v,a=res;n=(0.5*a.degrees/Math.acos(r.mm/(r.mm+v.mm))).round;m=n;m+=1 until m%4==0;b=0.5*a/m;s=2.0*r*Math.sin(b.degrees);puts"Rad.=#{r}mm, Tol.=#{v}mm, Ang.=#{a}°, Num.Segs=#{n}, %4=#{m}, Seg.Len.=#{s}mm>=0.001\"=#{s.mm>=0.001}";end;
Note how the 1/1000" is represented by 0.0254, the equivalent in mm. The default Radius is 25.0mm. The default Angle is 360° for a circle.
If there is sufficient interest it's easy enough to make it into a standalone plugin...
-
I want to start running a CNC mill based on my sketchup drawings. I am going to make aluminum parts for my truck and then market them once I have them correct.
Sketchup is all I have ever used but never in a way where my drawing will directly transfer to a machine for cutting. My main worry is how many segments to draw to have a nice final CNC product.
When looking for a circle segment rule of thumb I came across this post and have applied some of the math into a spreadsheet to understand what my limitations might be.
From your post I have come up with this to complete calculations in excel
degree 1 (d1) = 360 degrees / Segment # (S#)
degree 2 (d2) = d1 / 2
Radius of circle (r) = Perpendicular length from segment midpoint to circle center (PL) + Versine (TOL)
PL=r-TOL
Cos(d2)=PL/r
Cos(d1/2) =((r-TOL)/r)
Cos(360/(2*S#))=(1-(TOL/r))
Cos(180/S#)=(1-(TOL/r))
(180/S#)=ACos(1-(TOL/r))
S#=180/ACos(1-(TOL/r))
r=TOL/(1-(Cos(180/S#)))For excel:
S#=(180/(DEGREES(ACOS((1-(TOL/r))))))
r=(TOL/(1-(COS(RADIANS((180/S#))))))For drawing small parts accurately I typically scale up 1 million to 100 million times to make the number entry without decimals. This totally eliminates the failures of sketchup with small dimensions.
What I find is sketchup starts to get slow or crashes when I use large numbers of segments. What I have found is past 100 segments some extensions do not want to work correctly.
Based on a limit of 100 segments and a Versine tolerance of 0.001 inches that will limit me to a radius of 2 inches. Sketchup will allow 999 segments but I doubt the program will function.
Now to my question:
Is there an intermediate program that I can import my low segmented circle sketchup model into to ready the model for printing or cutting smooth circles. This would allow me to continue to use sketchup instead of learning another CAD program to facilitate my CNC work.
-
This was really aimed at arcs/circles used to extrude parts into 3d forms.
For example exported into 3d CAD files.
Remember that a 2d CAD file export will produce faceted arcs/circles whatever you do.
If you want to make fully smooth arc/circles then you can always model as 2d [to avoid any extrusions locking the form], then export that as a 3d CAD file.
A 3d CAD file [in contrast to 2d] uses true arcs/circles, without any faceting.So, if you are looking to export simple 2d CNC cutting profiles, then consider using them in 3d CAD file exports, to fully smooth them...
-
@tig said:
This was really aimed at arcs/circles used to extrude parts into 3d forms.
For example exported into 3d CAD files.
Remember that a 2d CAD file export will produce faceted arcs/circles whatever you do.
If you want to make fully smooth arc/circles then you can always model as 2d [to avoid any extrusions locking the form], then export that as a 3d CAD file.
A 3d CAD file [in contrast to 2d] uses true arcs/circles, without any faceting.So, if you are looking to export simple 2d CNC cutting profiles, then consider using them in 3d CAD file exports, to fully smooth them...
Other then sometimes lines will intersect at different locations based on how many segments are utilized. I have attached a vent handle that I modeled with plans to cut out of billet aluminum. I am preparing models prior to purchasing a machine. I modeled the handle 100,000,000 times larger than needed to eliminate errors from Sketchup. It is in inches.
My plan is to model and cut dress up items for show vehicles so my final product has to be cut perfect.
I have spent so much time with sketchup that I do not want to use a different CAD program. Hopefully the CNC can compensate and provide me with a smooth final product.
-
Scaling up to avoid faceting and other small visible geometry issues is a well known workaround.
The guys who developed Flowify devised and use this method to model classical columns in the minutest detail - they are miles high in the SKP !Because you are incorporating complex 3d geometry into the form then the suggested 3d-gives-true-circles in a CAD file export etc is of no use - it's only useful if the geometry is 'flat' - e.g. for 2d CNC cutting...
-
@tig said:
Scaling up to avoid faceting and other small visible geometry issues is a well known workaround.
The guys who developed Flowify devised and use this method to model classical columns in the minutest detail - they are miles high in the SKP !Because you are incorporating complex 3d geometry into the form then the suggested 3d-gives-true-circles in a CAD file export etc is of no use - it's only useful if the geometry is 'flat' - e.g. for 2d CNC cutting...
Sorry to beat this dead horse but I am still trying to establish a go forward plan.
1: Is there another CAD program that could smooth Sketchup 3-D shapes for use with a CNC?
2: I have not used any other CAD programs so if Sketchup can not provide what I want what are some easily learned CAD programs that will provide a smooth complex 3-D surface?
Thank you for your reply's.
Advertisement