void _coilKindScalarFilterPeronaMalik(coil_t *delta, coil_t **iv3, double spacing[3], double parm[COIL_PARMS_NUM]) { coil_t forwX[3], backX[3], forwY[3], backY[3], forwZ[3], backZ[3], KK, rspX, rspY, rspZ; /* reciprocals of spacings in X, Y, and Z */ rspX = AIR_CAST(coil_t, 1.0/spacing[0]); rspY = AIR_CAST(coil_t, 1.0/spacing[1]); rspZ = AIR_CAST(coil_t, 1.0/spacing[2]); _coilKindScalar3x3x3Gradients(forwX, backX, forwY, backY, forwZ, backZ, iv3, rspX, rspY, rspZ); /* compute fluxes */ KK = AIR_CAST(coil_t, parm[1]*parm[1]); forwX[0] *= _COIL_CONDUCT(ELL_3V_DOT(forwX, forwX), KK); forwY[1] *= _COIL_CONDUCT(ELL_3V_DOT(forwY, forwY), KK); forwZ[2] *= _COIL_CONDUCT(ELL_3V_DOT(forwZ, forwZ), KK); backX[0] *= _COIL_CONDUCT(ELL_3V_DOT(backX, backX), KK); backY[1] *= _COIL_CONDUCT(ELL_3V_DOT(backY, backY), KK); backZ[2] *= _COIL_CONDUCT(ELL_3V_DOT(backZ, backZ), KK); delta[0] = AIR_CAST(coil_t, parm[0])*(rspX*(forwX[0] - backX[0]) + rspY*(forwY[1] - backY[1]) + rspZ*(forwZ[2] - backZ[2])); }
void _coilKindScalarFilterModifiedCurvature(coil_t *delta, coil_t **iv3, double spacing[3], double parm[COIL_PARMS_NUM]) { coil_t forwX[3], backX[3], forwY[3], backY[3], forwZ[3], backZ[3], grad[3], gm, eps, KK, LL, denom, rspX, rspY, rspZ, lerp; /* reciprocals of spacings in X, Y, and Z */ rspX = AIR_CAST(coil_t, 1.0/spacing[0]); rspY = AIR_CAST(coil_t, 1.0/spacing[1]); rspZ = AIR_CAST(coil_t, 1.0/spacing[2]); _coilKindScalar3x3x3Gradients(forwX, backX, forwY, backY, forwZ, backZ, iv3, rspX, rspY, rspZ); grad[0] = rspX*(iv3[2][4] - iv3[0][4]); grad[1] = rspY*(iv3[1][5] - iv3[1][3]); grad[2] = rspZ*(iv3[1][7] - iv3[1][1]); gm = AIR_CAST(coil_t, ELL_3V_LEN(grad)); /* compute fluxes */ eps = 0.000001f; KK = AIR_CAST(coil_t, parm[1]*parm[1]); LL = ELL_3V_DOT(forwX, forwX); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); forwX[0] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(forwY, forwY); forwY[1] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(forwZ, forwZ); forwZ[2] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(backX, backX); backX[0] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(backY, backY); backY[1] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(backZ, backZ); backZ[2] *= _COIL_CONDUCT(LL, KK)*denom; lerp = AIR_CAST(coil_t, parm[2]); delta[0] = (lerp*_coilLaplacian3(iv3, spacing) + (1-lerp)*gm*(rspX*(forwX[0] - backX[0]) + rspY*(forwY[1] - backY[1]) + rspZ*(forwZ[2] - backZ[2]))); delta[0] *= AIR_CAST(coil_t, parm[0]); }
/* ** parm vector: ** 0 1 2 3 4 5 (6) ** step K_perp K_tan lerp X_ring Y_ring */ void _coilKindScalarFilterModifiedCurvatureRings(coil_t *delta, int xi, int yi, int zi, coil_t **iv3, double spacing[3], double parm[COIL_PARMS_NUM]) { coil_t forwX[3], backX[3], forwY[3], backY[3], forwZ[3], backZ[3], grad[3], gm, eps, KK, LL, denom, rspX, rspY, rspZ, lerp; double bas0[3], bas1[3], bas2[3], len, norm[3], sk; AIR_UNUSED(zi); ELL_3V_SET(bas0, 0, 0, 1); ELL_3V_SET(bas1, xi - parm[4], yi - parm[5], 0); ELL_3V_NORM(bas1, bas1, len); ELL_3V_CROSS(bas2, bas0, bas1); rspX = AIR_CAST(coil_t, 1.0/spacing[0]); rspY = AIR_CAST(coil_t, 1.0/spacing[1]); rspZ = AIR_CAST(coil_t, 1.0/spacing[2]); _coilKindScalar3x3x3Gradients(forwX, backX, forwY, backY, forwZ, backZ, iv3, rspX, rspY, rspZ); grad[0] = rspX*(iv3[2][4] - iv3[0][4]); grad[1] = rspY*(iv3[1][5] - iv3[1][3]); grad[2] = rspZ*(iv3[1][7] - iv3[1][1]); gm = AIR_CAST(coil_t, ELL_3V_LEN(grad)); if (gm) { double tc, rcsq; ELL_3V_SCALE(norm, 1.0/gm, grad); tc = ELL_3V_DOT(norm, bas2); rcsq = 1 - tc*tc; sk = AIR_LERP(rcsq, parm[1], parm[2]); } else { sk = parm[1]; } /* compute fluxes */ eps = 0.0000000001f; KK = AIR_CAST(coil_t, sk*sk); LL = ELL_3V_DOT(forwX, forwX); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); forwX[0] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(forwY, forwY); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); forwY[1] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(forwZ, forwZ); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); forwZ[2] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(backX, backX); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); backX[0] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(backY, backY); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); backY[1] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(backZ, backZ); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); backZ[2] *= _COIL_CONDUCT(LL, KK)*denom; lerp = AIR_CAST(coil_t, parm[2]); delta[0] = (lerp*_coilLaplacian3(iv3, spacing) + (1-lerp)*gm*(rspX*(forwX[0] - backX[0]) + rspY*(forwY[1] - backY[1]) + rspZ*(forwZ[2] - backZ[2]))); delta[0] *= AIR_CAST(coil_t, parm[0]); }
/* ** (mcde) ** parm vector: ** 0 1 2 (3) ** step K lerp (lerp=1: all laplacian) */ void _coilKindScalarFilterModifiedCurvature(coil_t *delta, int xi, int yi, int zi, coil_t **iv3, double spacing[3], double parm[COIL_PARMS_NUM]) { /* char me[]="_coilKindScalarFilterModifiedCurvature"; */ coil_t forwX[3], backX[3], forwY[3], backY[3], forwZ[3], backZ[3], grad[3], gm, eps, KK, LL, denom, rspX, rspY, rspZ, lerp; AIR_UNUSED(xi); AIR_UNUSED(yi); AIR_UNUSED(zi); /* if (coilVerbose) { fprintf(stderr, "!%s: --------- hello --------\n", me); } */ /* reciprocals of spacings in X, Y, and Z */ rspX = AIR_CAST(coil_t, 1.0/spacing[0]); rspY = AIR_CAST(coil_t, 1.0/spacing[1]); rspZ = AIR_CAST(coil_t, 1.0/spacing[2]); _coilKindScalar3x3x3Gradients(forwX, backX, forwY, backY, forwZ, backZ, iv3, rspX, rspY, rspZ); grad[0] = rspX*(iv3[2][4] - iv3[0][4]); grad[1] = rspY*(iv3[1][5] - iv3[1][3]); grad[2] = rspZ*(iv3[1][7] - iv3[1][1]); gm = AIR_CAST(coil_t, ELL_3V_LEN(grad)); /* if (coilVerbose) { fprintf(stderr, "forwX = %g %g %g backX = %g %g %g\n", forwX[0], forwX[1], forwX[2], backX[0], backX[1], backX[2]); fprintf(stderr, "forwY = %g %g %g backY = %g %g %g\n", forwY[0], forwY[1], forwY[2], backY[0], backY[1], backY[2]); fprintf(stderr, "forwZ = %g %g %g backZ = %g %g %g\n", forwZ[0], forwZ[1], forwZ[2], backZ[0], backZ[1], backZ[2]); fprintf(stderr, "grad = %g %g %g --> gm = %g\n", grad[0], grad[1], grad[2], gm); } */ /* compute fluxes */ eps = 0.0000000001f; KK = AIR_CAST(coil_t, parm[1]*parm[1]); LL = ELL_3V_DOT(forwX, forwX); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); forwX[0] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(forwY, forwY); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); forwY[1] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(forwZ, forwZ); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); forwZ[2] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(backX, backX); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); backX[0] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(backY, backY); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); backY[1] *= _COIL_CONDUCT(LL, KK)*denom; LL = ELL_3V_DOT(backZ, backZ); denom = AIR_CAST(coil_t, 1.0/(eps + sqrt(LL))); backZ[2] *= _COIL_CONDUCT(LL, KK)*denom; lerp = AIR_CAST(coil_t, parm[2]); delta[0] = (lerp*_coilLaplacian3(iv3, spacing) + (1-lerp)*gm*(rspX*(forwX[0] - backX[0]) + rspY*(forwY[1] - backY[1]) + rspZ*(forwZ[2] - backZ[2]))); delta[0] *= AIR_CAST(coil_t, parm[0]); /* if (coilVerbose) { fprintf(stderr, "!%s: delta = %g\n", me, delta[0]); } */ }