/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author nbriere */ public class MandelBulb extends Object3D { public boolean inside(double x, double y, double z, boolean transform) // , double d) { double d = 1; // Oops not so easy double posX = x; double posY = y; double posZ = z; double dr = 1.0; double r = 0.0; for (int i = 0; i < 10; i++) { double dist2xy = x*x + y*y; r = Math.sqrt(dist2xy + z*z); if (r > 10000) { break; } // convert to polar coordinates //double theta = Math.acos(z / r); double theta = Math.atan2(-z, Math.sqrt(dist2xy)); double phi = Math.atan2(y, x); double zr = Math.pow(r, 8); dr = zr / r * 8 * dr + 1.0; // scale and rotate the point theta = theta * 8; phi = phi * 8; // convert back to cartesian coordinates double sintheta = zr * Math.sin(theta); x = sintheta * Math.cos(phi); y = Math.sin(phi) * sintheta; z = zr * Math.cos(theta); x += posX; y += posY; z += posZ; } return ((0.5 * Math.log(r) * r / dr) < d); } }