{"id":16254299,"url":"https://github.com/celer/csg","last_synced_at":"2025-03-19T21:30:28.068Z","repository":{"id":57532995,"uuid":"214291786","full_name":"celer/csg","owner":"celer","description":"Constructive Solid Geometry (CSG) and Quick Hull Library for golang","archived":false,"fork":false,"pushed_at":"2019-10-30T16:15:35.000Z","size":1961,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T10:54:31.943Z","etag":null,"topics":["3d","3d-printing","csg","golang","hull"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/celer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-10T21:48:53.000Z","updated_at":"2025-02-06T21:18:48.000Z","dependencies_parsed_at":"2022-09-26T18:20:42.262Z","dependency_job_id":null,"html_url":"https://github.com/celer/csg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celer%2Fcsg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celer%2Fcsg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celer%2Fcsg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celer%2Fcsg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/celer","download_url":"https://codeload.github.com/celer/csg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244507828,"owners_count":20463689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d","3d-printing","csg","golang","hull"],"created_at":"2024-10-10T15:21:01.779Z","updated_at":"2025-03-19T21:30:27.550Z","avatar_url":"https://github.com/celer.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\n\nThis is a Constructive Solid Geometry and Quick Hull implemention in golang. \n\nThe CSG implementation is based upon https://github.com/jscad/csg.js/\n\nThe QuickHull implementation is based upon https://www.cs.ubc.ca/~lloyd/java/quickhull3d.html\n\nYou should also investigate SDFs as a better alternative to traditional CSG methods, see https://github.com/deadsy/sdfx\n\n# Basic usage\n\n## CSG\n\n```golang\ns1 := NewCube(\u0026CubeOptions{Size: \u0026Vector{2, 2, 2}})\ns2 := NewSphere(\u0026SphereOptions{Center: \u0026Vector{1, 1, 1}, Radius: 1.2, Slices: 15, Stacks: 15})\n    \nc:=s1.Subtract(s2)\n\nout, err := os.Create(\"v.stl\")\nif err != nil {\n    panic(err)\n}\nc.MarshalToASCIISTL(out)\nout.Close()\n\n```\n\nwill result in:\n\n![Image of resulting subtraction](/images/subtract.png)\n\n\n## Hulling shapes:\n\n```golang\nh := \u0026Hull{}\n\ns1 := csg.NewSphere(\u0026csg.SphereOptions{Center: \u0026csg.Vector{0, 0, 0}})\ns2 := csg.NewSphere(\u0026csg.SphereOptions{Center: \u0026csg.Vector{4, 0, -4}})\ns3 := csg.NewSphere(\u0026csg.SphereOptions{Center: \u0026csg.Vector{4, 0, 4}})\n\nerr := h.BuildFromCSG([]*csg.CSG{s1, s2, s3})\nif err != nil {\n\tpanic(err)\n}\n\nc := h.ToCSG()\nout, err := os.Create(\"v.stl\")\nif err != nil {\n\tpanic(err)\n}\nc.MarshalToASCIISTL(out)\nout.Close()\n```\n\nwill result in:\n\n![Image of resulting hull](/images/hull.png)\n\n\n\n\n# Why?\n\nI do a lot of OpenSCAD programming and I was hoping to find a way to build a more preformant and automatable tool-chain for 3D programming, plus I wanted to get my 3D math and understanding to a better place. Anyways while building this library I discovered SDFs (Signed Distance Functions), which is where I'll re-focus my efforts because it they seem like ultimately a more flexible approach to CSG rather then a mesh or polygon approach, I recommend seeing https://github.com/deadsy/sdfx as it's where I'm going to refocus my efforts. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceler%2Fcsg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceler%2Fcsg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceler%2Fcsg/lists"}