# How to create 3D shape via a math function?

21 Mar 2011 20:03 - 21 Mar 2011 20:24 #7983 by steve714
I wish to machine a math sculpture in 3d, for example, a sinc function [z=(sin(x)/(x)].

The equation is in 2D, and it needs to be set up along the x and z axis, then rotated symmetrically around the z-axis in the x-y plane to create the 3D image. The result would look like a sombrero hat.

It may be possible to create the 3D image in another program like MathCad, but how could I get it into AXiS (or PythonVCP)?
##### Attachments:
Last edit: 21 Mar 2011 20:24 by steve714. Reason: Add image

21 Mar 2011 20:41 - 21 Mar 2011 20:46 #7984 by BigJohnT
You have to convert it to G-Code with a cam program.

Inkscape has a plug in to create g-code do a search on the forum for it... it might do what you want.

John
Last edit: 21 Mar 2011 20:46 by BigJohnT.

23 Mar 2011 04:00 #8017 by steve714
Thanks, John. I will try out the Inscape CAM plug-in. I will also try to create the 2D Sinx/x function in Python, then call it as a subroutine and incrementing the z-axis to get the polar 3D image into AXIS.

Steve

23 Mar 2011 13:17 #8028 by andypugh
steve714 wrote:

I wish to machine a math sculpture in 3d, for example, a sinc function [z=(sin(x)/(x)].
The equation is in 2D, and it needs to be set up along the x and z axis, then rotated symmetrically around the z-axis in the x-y plane to create the 3D image. The result would look like a sombrero hat.

With a milling machine, and centred at (0,0)

#1 = 0.01
O100 while [#1 LT 1800]
G0 Z1
G0 X[#1 / 400]
G1 F1 Z[SIN[#1]/#1]
G3 F1 I0 J0
#1 = [#1 + 5]
O100 ENDWHILE
M2

(Never underestimate the power of raw G-code)

27 Mar 2011 00:25 #8134 by steve714
Thanks, Andy for the great "Raw" Gcode idea.

It took awhile to try your code, but I could not get AXIS to stop complaining about the G3 line of code.

I also tried G3 F12 X0 Y0 I0 J0 which generated a new set of errors. Other attempts at displaying the toolpaths in NCPlot, CamBamFree and Discriminator did not succeed either.

Still a GCODE newbie, but having fun trying! Steve

27 Mar 2011 12:19 #8155 by BigJohnT
If you can define it in a subroutine with parameters then you can use ngcgui and design on the fly right in Axis.

John

27 Mar 2011 17:41 #8165 by Rick G
May not be what you had in mind but will show a Gcode loop based on Andy's code.

#1 = 0.01
;O100 while [#1 LT 1800]
O100 while [#1 LT 180]
G0 Z1
G0 X[#1 / 400]
G1 F100 Z[SIN[#1]/#1]
;G3 F100 I0 J0
G3 F100 I0.5 J0.5
#1 = [#1 + 5]
O100 ENDWHILE
M2

27 Mar 2011 19:39 #8169 by dgarrett
An example 3d shape (sin(x)/x) using ngcgui:

#### File Attachment:

File Name: sinc-056e5...7fff.ngc
File Size:2 KB
##### Attachments:

27 Mar 2011 21:01 #8171 by andypugh
steve714 wrote:

It took awhile to try your code, but I could not get AXIS to stop complaining about the G3 line of code.

I should have pointed out that it was untested code, written off the top of my head, with no access to a CNC machine at the time.
The problem is that I forgot that IJ format arcs are incremental by default. The code I showed will work if you put G90.1 at the beginning. Alternatively make the G3 line say
G3 F1 I [#1 / -400]