Skip to content

Instantly share code, notes, and snippets.

@arnholm
Last active March 28, 2020 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnholm/e8eacdfb0293e3ddc7cc4705c189ffaf to your computer and use it in GitHub Desktop.
Save arnholm/e8eacdfb0293e3ddc7cc4705c189ffaf to your computer and use it in GitHub Desktop.
// AngelCAD code.

shape@ main_shape()
{
   // create cube & sphere in default positions
   double d = 100;
   solid@ mycub = cube(size:d);
   solid@ mysph = sphere(r:d*0.8);

   // create intersection between cube and sphere
   solid@ xsect = mycub & translate(0,0,d)*mysph;
   
   // get the bounding box of the intersection
   boundingbox@ b = xsect.box();
   
   // print the bounding box ranges in x,y and z
   cout << "xlow, xhigh = " << b.p1().x() << ' ' << b.p2().x() << endl;
   cout << "ylow, yhigh = " << b.p1().y() << ' ' << b.p2().y() << endl;
   cout << "zlow, zhigh = " << b.p1().z() << ' ' << b.p2().z() << endl;
   
   // output from the above is
   //
   // xlow, xhigh = 0 80
   // ylow, yhigh = 0 80
   // zlow, zhigh = 20 100

   return xsect;
}

void main()
{
   shape@ obj = main_shape();
   obj.write_xcsg(GetInputFullPath(),secant_tolerance:-1.0);
}
Display the source blob
Display the rendered blob
Raw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment