Hacker Newsnew | past | comments | ask | show | jobs | submit | deadsy's commentslogin

I wrote this (in golang) to satisfy my need to generate STLs for 3d printing.

https://github.com/deadsy/sdfx

In general I like to write code to define objects, but there are some situations where a graphical editing UI would be nice. ie- Curve and polygon design.

You can sort of imagine a hybrid approach where you could crack open a mini editor to design a curve and then use it to generate code (table of numbers) which you could then extrude/sweep/loft or whatever.


A hybrid approach where you could "sketch" with SolveSpace, but then generate OpenSCAD style code that you could later edit would be amazing.

The main advantage of OpenSCAD is that it doesn't "blow up" when you change a variable to be out of some range where things work. In OpenSCAD, you can put it back if it does cause a problem.

Changing a dimension in SolveSpace sometimes throws off the whole design. SolveSpace's precision, constraints, and great keyboard user interface make it a fun program to design parts in. It is among the best open source tools out there.


Alternately, it would be way cool to have a modeling language which would make designs for Solvespace.


I started with OpenSCAD but: a) found the language to be clunky b) had a hard time doing chamfered unions between objects (needed for sand casting patterns).

So - I wrote my own tool/library in Go and it's essentially replaced my OpenSCAD usage.

https://github.com/deadsy/sdfx


>> So - I wrote my own tool/library in Go and it's essentially replaced my OpenSCAD usage.

That looks really cool. What kind of files can it output?


Well, I looked at the linked page[0] and it says STL files.

0. https://github.com/deadsy/sdfx


3d = stl, 2d = svg or dxf


The examples in your README look cool. But, I was wondering about this sentence:

> SDFs make CSG easy

Can you share some more info about how this works?


SDF = signed distance function. A function mapping a 2d/3d coordinate onto a scalar. The scalar is the shortest distance from that point to the surface of the object. (+ve outside, -ve inside)

CSG = constructive solid geometry: Take primitive 3d shapes and do unions, differences, intersections on them to build more complex shapes.

Fairly obviously the union of 2 sdf functions is going to be the minimum of those values. That pretty simple.

Intersections and differences are not much more complex....

See: https://iquilezles.org/www/articles/distfunctions/distfuncti...

for some quick examples.


I wrote a CAD package in Go that has a function for it.

https://github.com/deadsy/sdfx

  func InvoluteGear(
   numberTeeth int, // number of gear teeth
   gearModule float64, // pitch circle diameter / number of gear teeth
   pressureAngle float64, // gear pressure angle (radians)
   backlash float64, // backlash expressed as per-tooth distance at pitch circumference
   clearance float64, // additional root clearance
   ringWidth float64, // width of ring wall (from root circle)
   facets int, // number of facets for involute flank
  )


You sequence the motor, get a pick up from the light sensor and then turn it into a note trigger. It'd be simpler to sequence an array rather than a motor and generate a trigger based on array content.

But sure. Art. It's a piece of kinetic sculpture....


True. But then you lose the ability to generate a new sequence by cutting out a piece of paper...!


Yeah the whole point is to make it loose and organic instead of rigid and quantized :)


Right - they statically link which means that you typically don't have to worry about shared object dependencies when moving the binary around. You just have big binaries. If you use cgo (integration with C-code and C based libraries) then you are back to *.so versioning problems.


You still have to worry about other factors such as byte-swapped platforms (big- vs. little-endian).


Right. I've mentioned this in the article now.


Premise: It's more important to be productive than to have fast code. Conclusion: Use Python. Is the premise true? For many cases- yes, but it depends. If you are running an application on the cloud and your metric is $/user/year and you have many users then saving some compute resources for each user gets attractive and you don't want to just throw another VM at it.

Is the conclusion true? Garbage collection gives big productivity gains. Other languages have GC. It's not nice to see your Python code die after a few days because you messed up the type passed to a function. Other languages fix that at compile time. Multicore is now. Other languages are built with better multicore awareness.


As an engineer hiring engineers, if a candidate gives me a guthub url then I'm going to take a look. There are too many people coming through the door who are marginal coders, so if I can get a sense of what they do for something other than a white board problem then that's a good thing.


>Even something seemingly simple such as saying "is point C to the left or right of the line A->B" is very hard in floating point.

Is it? ie - construct a normal and take a dot product. That'll work the vast majority of the time. Near the line you'll start running into the FP precision limits. With 64 (...or even 32) bit floats that sort of distance is likely way smaller than anything that represents a practical distance, so just call it and say you are on the line. Of late I've been messing about with problems of this nature and I can't say it's been all that difficult. https://github.com/deadsy/sdfx


It comes back to bite you in a hurry. You don't need arbitrary precision to represent arbitrarily small things but to not have algorithms break down. Simple things like "is p inside the polygon" changes from true to false by moving both point and polygon 1 unit to the right. See under the heading "geometric predicates can FAIL" here http://groups.csail.mit.edu/graphics/classes/6.838/S98/meeti...

You are right that this happens only in edge cases. But you don't want that in a cad program if you have anything doing e.g point-in-polygon, triangulation or other such algorithms.

I know from experience that you really should bake this into the very foundation of a cad package (if you see 2003 me, let him know)


The link didn't work when I tried it. I found "Robust Predicates and Degeneracy" with a search: http://groups.csail.mit.edu/graphics/classes/6.838/S98/meeti...


Thanks, not sure why my iOS clipboard pasted a link I copied a week ago... (corrected the link now)


There are other tooth forms that also satisfy the fundamental law of gearing (constant ratio of angular velocity). E.g. cycloid gearing used typically in mechanical clocks. The involute is popular because its easy to manufacture. It can be auto-generated on a gear hobbing machine- probably less important now with CNC machines, but very important in a pre-digital machine era. The involute is also less sensitive to gear center to center spacing.


When I was in Stuttgart I made a point of visiting the one they have in the Rathaus. It's an interesting mechanical design, but definitely assumes some personal responsibility on the part of the user. Keep your hands to yourself as you go around the top and bottom...


Actually they have two in the Rathaus, a modern one in the front and an older one towards the back. One of the university buildings has one too.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: