MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / drawSphere

Method drawSphere

ij/src/main/java/ij/ImageStack.java:621–639  ·  view source on GitHub ↗

Experimental

(double radius, int xc, int yc, int zc)

Source from the content-addressed store, hash-verified

619
620 /** Experimental */
621 public void drawSphere(double radius, int xc, int yc, int zc) {
622 int diameter = (int)Math.round(radius*2);
623 double r = radius;
624 int xmin=(int)(xc-r+0.5), ymin=(int)(yc-r+0.5), zmin=(int)(zc-r+0.5);
625 int xmax=xmin+diameter, ymax=ymin+diameter, zmax=zmin+diameter;
626 double r2 = r*r;
627 r -= 0.5;
628 double xoffset=xmin+r, yoffset=ymin+r, zoffset=zmin+r;
629 double xx, yy, zz;
630 for (int x=xmin; x<=xmax; x++) {
631 for (int y=ymin; y<=ymax; y++) {
632 for (int z=zmin; z<=zmax; z++) {
633 xx = x-xoffset; yy = y-yoffset; zz = z-zoffset;
634 if (xx*xx+yy*yy+zz*zz<=r2)
635 setVoxel(x, y, z, 255);
636 }
637 }
638 }
639 }
640
641
642 /** Returns the bit depth (8=byte, 16=short, 24=RGB, 32=float). */

Callers

nothing calls this directly

Calls 2

setVoxelMethod · 0.95
roundMethod · 0.45

Tested by

no test coverage detected