morphologica icon indicating copy to clipboard operation
morphologica copied to clipboard

Is there a function to draw a circle based on the center coordinates and radius

Open wangce888 opened this issue 2 years ago • 2 comments

wangce888 avatar Aug 03 '22 07:08 wangce888

All the primitive drawing functions are found in morph/VisualModel.h. They have names like "computeCone" and "computeSphere". I've drawn "circles" before in the graphing code, GraphVisual (to represent the datapoints in a graph). The circles in that case are make up of a fan of triangles - so the circle is a solid disc. The function that achieves this is VisualModel::computeFlatPoly. This is a general purpose function to create a flat polygon. To make a circle, you choose the 'segments' argument to be large enough that the polygon looks like a circle to the viewer.

If instead of a 'disc circle' you need a ring, then you can look at VisualModel::computeRing. This creates a ring made up of quads (so it's a flat ring as if cut from a sheet of paper, not a ring made of tubes like a hula-hoop).

Hope that's helpful and that one of these does what you need. What would you like to draw circles for?

sebjameswml avatar Aug 03 '22 07:08 sebjameswml

To see how these drawing primitives are used in a VisualModel-derived class that actually creates a graphical model, see, for examples morph/RodVisual.h which contains morph::RodVisual and look at the initializeVertices() function. That one is a very simple model, as it makes one call to VisualModel::computeTube. For a slightly more complex example, see morph/CoordArrows.h which contains morph::CoordArrows which creates 3D coordinate arrows from tubes, spheres and cones.

sebjameswml avatar Aug 03 '22 08:08 sebjameswml

I hope that helped. Closing this question now.

sebjameswml avatar Sep 11 '22 12:09 sebjameswml