|
I've
already seen several answers to your question, but I'm coming with my suggestion
too.
I'm
supposing that you want to have not a raster image of a circle, but a real 3d
circle that you can manipulate like any other shape3d. If it's not the case,
just forget that email.
For
that, you need to create a geometry containing the "circle", which in fact
is an aproximation of a circle, and then you just add it to the shape3d. Below
is the code to generate a 3d circle in the XY plane. The circle has the center
at [0, 0, 0] and a radius of <radius>.
float radius
= ...;
// 32 segments = 33 points. int resolution = 32; int length = resolution + 1; LineStripArray lsa = new LineStripArray(length, GeometryArray.COORDINATES, new int[] {length}); // first and last points Point3f pt0 = new Point3f(radius, 0.0f, 0.0f); lsa.setCoordinate(0, pt0); // computed points Point3f pt = new Point3f(); for (int i = 1; i < 32; i++) { pt.x = (float)(radius * Math.cos(i * Math.PI / 16)); pt.y = (float)(radius * Math.sin(i * Math.PI / 16)); lsa.setCoordinate(i, pt); } lsa.setCoordinate(32, pt0); Shape3D circle = new Shape3D(lsa); Hope
that helps,
Florin
|
