public static double[] tangents_to_circle(double x, double y, double cx, double cy, double r){
		double[] result = NONE;
		double dx = cx - x;
		double dy = cy - y;
		double dxSQ = dx * dx;
		double dySQ = dy * dy;
		double denom = dxSQ + dySQ;

		double root = denom - r*r;

		if(root > -ACCY){
			double denomINV = 1.0f/denom;
			double A, B;

			if(root < ACCY){ // point is on circle
				A = -r*dx*denomINV;
				B = -r*dy*denomINV;
				result = new double[] { cx + A*r, cy + B*r };
			}
			else {
				root = Math.sqrt(root);
				result = new double[4];
				A = (-dy*root - r*dx)*denomINV;
				B = (dx*root - r*dy)*denomINV;
				result[0] = cx + A*r;
				result[1] = cy + B*r;
				A = (dy*root - r*dx)*denomINV;
				B = (-dx*root - r*dy)*denomINV;
				result[2] = cx + A*r;
				result[3] = cy + B*r;	
			}
		}
		return result;
	}