def iterate4DJuliaSet(z3d): max_iterations = bpy.context.scene.Fractals.juliaSet.maxIterations threshold = bpy.context.scene.Fractals.juliaSet.bailout c_ref = bpy.context.scene.Fractals.juliaSet.c w_projection = bpy.context.scene.Fractals.juliaSet.projectionValue c = quat() c.x = c_ref[0] c.y = c_ref[1] c.z = c_ref[2] c.w = c_ref[3] z = quat() z.x = z3d.x z.y = z3d.y z.z = z3d.z z.w = w_projection iterations = 0 converged = 1 while(True): z = squareQ(z) + c iterations += 1 l = lengthQ(z) if(l > threshold): converged = 0 break if(iterations > max_iterations): break return converged
def iterate4DJuliaSet(z3d): max_iterations = bpy.context.scene.Fractals.juliaSet.maxIterations threshold = bpy.context.scene.Fractals.juliaSet.bailout c_ref = bpy.context.scene.Fractals.juliaSet.c w_projection = bpy.context.scene.Fractals.juliaSet.projectionValue c = quat() c.x = c_ref[0] c.y = c_ref[1] c.z = c_ref[2] c.w = c_ref[3] z = quat() z.x = z3d.x z.y = z3d.y z.z = z3d.z z.w = w_projection iterations = 0 converged = 1 while (True): z = squareQ(z) + c iterations += 1 l = lengthQ(z) if (l > threshold): converged = 0 break if (iterations > max_iterations): break return converged
def squareQ(Q): new_Q = quat() new_Q.x = Q.x*Q.x - Q.y*Q.y - Q.z*Q.z - Q.w*Q.w new_Q.y = 2*Q.x*Q.y new_Q.z = 2*Q.x*Q.z new_Q.w = 2*Q.x*Q.w return(new_Q)
def squareQ(Q): new_Q = quat() new_Q.x = Q.x * Q.x - Q.y * Q.y - Q.z * Q.z - Q.w * Q.w new_Q.y = 2 * Q.x * Q.y new_Q.z = 2 * Q.x * Q.z new_Q.w = 2 * Q.x * Q.w return (new_Q)