Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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);
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.