morphologica
morphologica copied to clipboard
Is there a function to draw a circle based on the center coordinates and radius
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?
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.
I hope that helped. Closing this question now.