Corrections put in PTFUN1 and PTFUN2.
authorilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Mon, 5 Feb 2018 23:10:37 +0000 (23:10 +0000)
committerilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Mon, 5 Feb 2018 23:10:37 +0000 (23:10 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15361 ba61647d-9d00-f842-95cd-605cb4296b96

mipav/src/gov/nih/mipav/model/algorithms/SymmsIntegralMapping.java

index 3e2b29b..b5cdd47 100644 (file)
@@ -457,6 +457,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                File file;\r
                RandomAccessFile raFile = null;\r
                boolean validInput;\r
+               String junk;\r
 \r
                // EXTERNAL CHRIN,HEADER,R1MACH,SYINF1,WRFUN1,WRFUN2,WRHEAD,WRSYM1,\r
                // +WRSYM2,WRSYM3,WRTAIL\r
@@ -484,7 +485,6 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                REDD = "E" + WID[SW - 1] + "." + SIG[SW - 1];\r
                // FMT1="("+REDD+")";\r
                // FMT2="(2"+REDD+")";\r
-\r
                if (traditionalInput) {\r
                        System.out.println("ENTER FILENAME TO RECEIVE OUTPUT JAVA CODE");\r
                        FORTFL = input.next();\r
@@ -559,7 +559,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                }\r
                                validInput = false;\r
                                while (!validInput) {\r
-                                       System.out.print("How many arcs are there on the fundamental boundary section?");\r
+                                       System.out.println("How many arcs are there on the fundamental boundary section?");\r
                                        NARCS = input.nextInt();\r
                                        if (NARCS <= MNARC - 1) {\r
                                                validInput = true;\r
@@ -700,6 +700,9 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                                } else {\r
                                                        System.out.println("ENTER JAVA EXPRESSION WITH NO SPACES ENDING IN // FOR RADIUS DERIVATIVE");\r
                                                }\r
+                                               // Java does not allow operator overloading, so you can't do a cos(t)*sin(t) for complex t.\r
+                                               System.out.println("Expand cos(complex T[]) as Math.cos(T[0])*Math.cosh(T[1]) - i*Math.sin(T[0])*Math.sinh(T[1])");\r
+                                               System.out.println("Expand sin(complex T[]) as Math.sin(T[0])*Math.cosh(T[1]) + i*Math.cos(T[0])*Math.sinh(T[1])");\r
 \r
                                                TXCO = TXCO + 1;\r
                                                PTX[IA - 1 + (J - 1) * MNARC] = TXCO;\r
@@ -769,6 +772,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                        } // while (!validInput)\r
                } // if (traditionalInput)\r
                HEADER("PARFUN", REDD, raFile);\r
+               \r
                if (SYMTY) {\r
                        SYINF1(ORDRG, ORDSG, RTUNI, U2, REFLN, CENSY, STAPT[0], STAPT[NARCS], IER);\r
                        if (IER[0] > 0) {\r
@@ -843,7 +847,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
 \r
                LINE = TAB6 + "double " + TXT + "ANS[] = new double[2];\n";\r
                raFile.writeBytes(LINE);\r
-               LINE = TAB6 + " double ZRAD[] = new double[2];\n";\r
+               LINE = TAB6 + "double ZRAD[] = new double[2];\n";\r
                raFile.writeBytes(LINE);\r
                LINE = TAB6 + "int IA;\n";\r
                raFile.writeBytes(LINE);\r
@@ -938,6 +942,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
        // COMPLEX FUNCTION PARFUN(I,T)\r
        // INTEGER I\r
        // COMPLEX T\r
+       // \r
        double[] PARFUN(int I, double T[]) {\r
 \r
                // DUMMY FUNCTION TO AID LINK-LOADING OF PARGEN\r
@@ -1346,8 +1351,8 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                String TX1, TX2;\r
                // String FMT1,FMT2;\r
                // EXTERNAL PTFUN1\r
-               TX1 = "     if(" + CHIA + " == ";\r
-               TX2 = "     else if(" + CHIA + " == ";\r
+               TX1 = "      if(" + CHIA + " == ";\r
+               TX2 = "      else if(" + CHIA + " == ";\r
                // FMT1="(A16,I3,A6)";\r
                // FMT2="(A21,I3,A6)";\r
                double STAPT2[][];\r
@@ -1406,7 +1411,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
 \r
        private void PTFUN1(int TYPE, double STAPT[][], double RGM[], int NTX, String TXT[], int CHNL, String CHTT,\r
                        String VAR, String REDD, RandomAccessFile raFile) {\r
-\r
+        // When TT goes from -1,0 to 1,0 T[0] traces out the original parameterization of the curve\r
                // COMPLEX STAPT(*)\r
                // CHARACTER TXT(*)*72,CHTT*2,VAR*6,REDD*6\r
 \r
@@ -1421,6 +1426,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                double C1[] = new double[2];\r
                double C2[] = new double[2];\r
                double CENTR[] = new double[2];\r
+               String PAD = "          ";\r
                // COMPLEX C1,C2,CENTR\r
                // String TX1, TX1B, TX2;\r
                // String TX2B, CTX1B, FMT1, FMT2, FMT3, FMT4, FMT5;\r
@@ -1447,9 +1453,9 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                C2[1] = 0.5 * (STAPT[1][1] - STAPT[0][1]);\r
                                raFile.writeBytes("//\n");\r
                                raFile.writeBytes(\r
-                                               VAR + "ANS[0] = " + C1[0] + "+" + CHTT + "[0]*(" + C2[0] + ") - " + CHTT + "[1]*(" + C2[1] + ");\n");\r
+                                               PAD + VAR + "ANS[0] = " + C1[0] + "+" + CHTT + "[0]*(" + C2[0] + ") - " + CHTT + "[1]*(" + C2[1] + ");\n");\r
                                raFile.writeBytes(\r
-                                               VAR + "ANS[1] = " + C1[1] + "+" + CHTT + "[0]*(" + C2[1] + ") + " + CHTT + "[1]*(" + C2[0] + ");\n");\r
+                                               PAD + VAR + "ANS[1] = " + C1[1] + "+" + CHTT + "[0]*(" + C2[1] + ") + " + CHTT + "[1]*(" + C2[0] + ");\n");\r
                                raFile.writeBytes("//\n");\r
                        } // if (TYPE == 1)\r
                        else if (TYPE == 2) {\r
@@ -1461,9 +1467,9 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                MD = Math.atan2(C1[1], C1[0]) + HA;\r
                                RAD = zabs(C1[0], C1[1]);\r
                                raFile.writeBytes("//\n");\r
-                               raFile.writeBytes(VAR + "ANS[0] = " + CENTR[0] + "+" + RAD + " * " + "Math.exp(-" + CHTT + "[1]*(" + HA\r
+                               raFile.writeBytes(PAD + VAR + "ANS[0] = " + CENTR[0] + "+" + RAD + " * " + "Math.exp(-" + CHTT + "[1]*(" + HA\r
                                                + "))*" + "Math.cos(" + MD + "+" + CHTT + "[0]*(" + HA + "));\n");\r
-                               raFile.writeBytes(VAR + "ANS[1] = " + CENTR[1] + "+" + RAD + " * " + "Math.exp(-" + CHTT + "[1]*(" + HA\r
+                               raFile.writeBytes(PAD + VAR + "ANS[1] = " + CENTR[1] + "+" + RAD + " * " + "Math.exp(-" + CHTT + "[1]*(" + HA\r
                                                + "))*" + "Math.sin(" + MD + "+" + CHTT + "[0]*(" + HA + "));\n");\r
                                raFile.writeBytes("//\n");\r
                        } // else if (TYPE == 2)\r
@@ -1471,39 +1477,55 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                MD = 0.5 * (RGM[1] + RGM[0]);\r
                                HA = 0.5 * (RGM[1] - RGM[0]);\r
                                raFile.writeBytes("//\n");\r
-                               raFile.writeBytes("T[0] = " + MD + "+" + CHTT + "[0] * (" + HA + ");\n");\r
-                               raFile.writeBytes("T[1] = " + CHTT + "[1] * (" + HA + ");\n");\r
+                               raFile.writeBytes(PAD + "T[0] = " + MD + "+" + CHTT + "[0] * (" + HA + ");\n");\r
+                               raFile.writeBytes(PAD + "T[1] = " + CHTT + "[1] * (" + HA + ");\n");\r
 \r
-                               raFile.writeBytes(VAR + "ANS[0] = ");\r
-                               // NTX = 1 if statements are entered without newlines for\r
-                               // multiple lines\r
-                               for (I = 1; I <= NTX; I++) {\r
-                                       int index = TXT[I - 1].indexOf("ui");\r
-                                       String realString = null;\r
-                                       if (index == -1) {\r
-                                               realString = TXT[I - 1];\r
-                                       } else {\r
-                                               realString = TXT[I - 1].substring(0, index);\r
-                                       }\r
-                                       if ((index == -1) || (index > 0)) {\r
-                                               raFile.writeBytes(realString);\r
-                                       }\r
-                                       if (I == NTX) {\r
-                                               raFile.writeBytes(";\n");\r
+                               if (TXT[0].indexOf("ui") == 0) {\r
+                                   raFile.writeBytes(PAD + VAR + "ANS[0] = 0.0;\n");\r
+                               }\r
+                               else {\r
+                                       // NTX = 1 if statements are entered without newlines for\r
+                                       // multiple lines\r
+                                       raFile.writeBytes(PAD + VAR + "ANS[0] = ");\r
+                                       for (I = 1; I <= NTX; I++) {\r
+                                               int index = TXT[I - 1].indexOf("ui");\r
+                                               String realString = null;\r
+                                               if (index == -1) {\r
+                                                       realString = TXT[I - 1];\r
+                                               } else {\r
+                                                       realString = TXT[I - 1].substring(0, index);\r
+                                               }\r
+                                               if ((index == -1) || (index > 0)) {\r
+                                                       raFile.writeBytes(realString);\r
+                                               }\r
+                                               if (I == NTX) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                               }\r
                                        }\r
                                }\r
-                               raFile.writeBytes(VAR + "ANS[1] = ");\r
+                               boolean uifound = false;\r
+                               for (I = 1; I <= NTX; I++) {\r
+                                   if (TXT[I-1].indexOf("ui") >= 0) {\r
+                                       uifound = true;\r
+                                   }\r
+                               }\r
+                               if (!uifound) {\r
+                                   raFile.writeBytes(PAD + VAR + "ANS[1] = 0.0;\n");\r
+                               }\r
+                               else {\r
                                // NTX = 1 if statements are entered without newlines for\r
                                // multiple lines\r
-                               for (I = 1; I <= NTX; I++) {\r
-                                       int index = TXT[I - 1].indexOf("ui");\r
-                                       String imagString = null;\r
-                                       if ((index >= 0) && (index + 2 < TXT[I - 1].length())) {\r
-                                               imagString = TXT[I - 1].substring(index + 2);\r
-                                               raFile.writeBytes(imagString);\r
-                                       }\r
-                                       if (I == NTX) {\r
-                                               raFile.writeBytes(";\n");\r
+                                       raFile.writeBytes(PAD + VAR + "ANS[1] = ");\r
+                                       for (I = 1; I <= NTX; I++) {\r
+                                               int index = TXT[I - 1].indexOf("ui");\r
+                                               String imagString = null;\r
+                                               if ((index >= 0) && (index + 2 < TXT[I - 1].length())) {\r
+                                                       imagString = TXT[I - 1].substring(index + 2);\r
+                                                       raFile.writeBytes(imagString);\r
+                                               }\r
+                                               if (I == NTX) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                               }\r
                                        }\r
                                }\r
                                raFile.writeBytes("//\n");\r
@@ -1512,19 +1534,61 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                MD = 0.5 * (RGM[1] + RGM[0]);\r
                                HA = 0.5 * (RGM[1] - RGM[0]);\r
                                raFile.writeBytes("//\n");\r
-                               raFile.writeBytes("T[0] = " + MD + "+" + CHTT + "[0] * (" + HA + ");\n");\r
-                               raFile.writeBytes("T[1] = " + CHTT + "[1] * (" + HA + ");\n");\r
-                               raFile.writeBytes("ZRAD = ");\r
-                               // NTX = 1 if statements are entered without newlines for\r
-                               // multiple lines\r
+                               raFile.writeBytes(PAD + "T[0] = " + MD + "+" + CHTT + "[0] * (" + HA + ");\n");\r
+                               raFile.writeBytes(PAD + "T[1] = " + CHTT + "[1] * (" + HA + ");\n");\r
+                               if (TXT[0].indexOf("ui") == 0) {\r
+                                   raFile.writeBytes(PAD + "ZRAD[0] = 0.0;\n");\r
+                               }\r
+                               else {\r
+                                       // NTX = 1 if statements are entered without newlines for\r
+                                       // multiple lines\r
+                                       raFile.writeBytes(PAD + "ZRAD[0] = ");\r
+                                       for (I = 1; I <= NTX; I++) {\r
+                                               int index = TXT[I - 1].indexOf("ui");\r
+                                               String realString = null;\r
+                                               if (index == -1) {\r
+                                                       realString = TXT[I - 1];\r
+                                               } else {\r
+                                                       realString = TXT[I - 1].substring(0, index);\r
+                                               }\r
+                                               if ((index == -1) || (index > 0)) {\r
+                                                       raFile.writeBytes(realString);\r
+                                               }\r
+                                               if (I == NTX) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                               }\r
+                                       }\r
+                               }\r
+                               boolean uifound = false;\r
                                for (I = 1; I <= NTX; I++) {\r
-                                       raFile.writeBytes(TXT[I - 1]);\r
+                                   if (TXT[I-1].indexOf("ui") >= 0) {\r
+                                       uifound = true;\r
+                                   }\r
                                }\r
-                               raFile.writeBytes(VAR + "ANS[0] = ZRAD[0]*Math.exp(-T[1])*Math.cos(T[0]) - ZRAD[1]*Math.exp(-T[1])*Math.sin(T[0]);\n");\r
-                               raFile.writeBytes(VAR + "ANS[1] = ZRAD[0]*Math.exp(-T[1])*Math.sin(T[0]) + ZRAD[1]*Math.exp(-T[1])*Math.cos(T[0]);\n");\r
+                               if (!uifound) {\r
+                                   raFile.writeBytes(PAD + "ZRAD[1] = 0.0;\n");\r
+                               }\r
+                               else {\r
+                                       // NTX = 1 if statements are entered without newlines for\r
+                                       // multiple lines\r
+                                       raFile.writeBytes(PAD + "ZRAD[1] = ");\r
+                                       for (I = 1; I <= NTX; I++) {\r
+                                               int index = TXT[I - 1].indexOf("ui");\r
+                                               String imagString = null;\r
+                                               if ((index >= 0) && (index + 2 < TXT[I - 1].length())) {\r
+                                                       imagString = TXT[I - 1].substring(index + 2);\r
+                                                       raFile.writeBytes(imagString);\r
+                                               }\r
+                                               if (I == NTX) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                               }\r
+                                       }\r
+                               }\r
+                               raFile.writeBytes(PAD + VAR + "ANS[0] = ZRAD[0]*Math.exp(-T[1])*Math.cos(T[0]) - ZRAD[1]*Math.exp(-T[1])*Math.sin(T[0]);\n");\r
+                               raFile.writeBytes(PAD + VAR + "ANS[1] = ZRAD[0]*Math.exp(-T[1])*Math.sin(T[0]) + ZRAD[1]*Math.exp(-T[1])*Math.cos(T[0]);\n");\r
                                raFile.writeBytes("//\n");\r
                        }\r
-                       raFile.writeBytes("return " + VAR + "ANS;\n");\r
+                       raFile.writeBytes(PAD + "return " + VAR + "ANS;\n");\r
                } // try\r
                catch (IOException e) {\r
                        MipavUtil.displayError("IOException " + e + " in PTFUN1");\r
@@ -1775,6 +1839,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                double HA, MD, RAD, A, R;\r
                double C1[] = new double[2];\r
                double CENTR[] = new double[2];\r
+               String PAD = "          ";\r
                // COMPLEX C1,CENTR\r
                // String TX1, TX1B, TX2, TX2B, TX3, FMT1, FMT2, FMT3, FMT4, FMT5;\r
                // CHARACTER TX1*4,TX1B*5,TX2*13,TX2B*14,TX3*39,\r
@@ -1802,8 +1867,8 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                raFile.writeBytes("//\n");\r
                                R = C1[0];\r
                                A = C1[1];\r
-                               raFile.writeBytes("      " + VAR + "ANS[0] = " + R + ";\n");\r
-                               raFile.writeBytes("      " + VAR + "ANS[1] = " + A + ";\n");\r
+                               raFile.writeBytes(PAD + VAR + "ANS[0] = " + R + ";\n");\r
+                               raFile.writeBytes(PAD + VAR + "ANS[1] = " + A + ";\n");\r
                                raFile.writeBytes("//\n");\r
                        } // if (TYPE == 1)\r
                        else if (TYPE == 2) {\r
@@ -1816,8 +1881,8 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                RAD = zabs(C1[0], C1[1]);\r
                                raFile.writeBytes("//\n");\r
                                raFile.writeBytes(\r
-                                               VAR + "ANS[0] = (-" + RAD + ")*(" + HA + ")*Math.exp((-"+CHTT + "[1])*(" + HA +"))*Math.sin(" + MD + "+(" + CHTT + "[0])*(" + HA + "));\n");\r
-                               raFile.writeBytes(VAR + "ANS[1] = (" + RAD + ")*(" + HA + ")*Math.exp((-"+CHTT + "[1])*Math.cos(" + MD + "+" + CHTT + "[0])*(" + HA + "));\n");\r
+                                               PAD + VAR + "ANS[0] = (-" + RAD + ")*(" + HA + ")*Math.exp((-"+CHTT + "[1])*(" + HA +"))*Math.sin(" + MD + "+" + CHTT + "[0]*(" + HA + "));\n");\r
+                               raFile.writeBytes(PAD + VAR + "ANS[1] = (" + RAD + ")*(" + HA + ")*Math.exp((-"+CHTT + "[1])*Math.cos(" + MD + "+" + CHTT + "[0]*(" + HA + "));\n");\r
                                raFile.writeBytes("//\n");\r
                        } // else if (TYPE == 2)\r
                        else if (NUMDER) {\r
@@ -1829,37 +1894,54 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                MD = 0.5 * (RGM[1] + RGM[0]);\r
                                HA = 0.5 * (RGM[1] - RGM[0]);\r
                                raFile.writeBytes("//\n");\r
-                               raFile.writeBytes("      T = " + MD + "+" + CHTT + "*" + "(" + HA + ");\n");\r
-                               raFile.writeBytes("      " + VAR + "ANS[0] = " + HA + "*(");\r
-                               // NTX2 = 1 if statements are entered without newlines for\r
-                               // multiple lines\r
-                               for (I = 1; I <= NTX2; I++) {\r
-                                       int index = TXT2[I - 1].indexOf("ui");\r
-                                       String realString = null;\r
-                                       if (index == -1) {\r
-                                               realString = TXT2[I - 1];\r
-                                       } else {\r
-                                               realString = TXT2[I - 1].substring(0, index);\r
-                                       }\r
-                                       if ((index == -1) || (index > 0)) {\r
-                                               raFile.writeBytes(realString);\r
-                                       }\r
-                                       if (I == NTX2) {\r
-                                               raFile.writeBytes(");\n");\r
+                               raFile.writeBytes(PAD + "T[0] = " + MD + "+" + CHTT + "[0]*(" + HA + ");\n");\r
+                               raFile.writeBytes(PAD + "T[1] = " + CHTT + "[1]*(" + HA + ");\n");\r
+                               if (TXT2[0].indexOf("ui") == 0) {\r
+                                   raFile.writeBytes(PAD + VAR + "ANS[0] = 0.0;\n");\r
+                               }\r
+                               else {\r
+                                       // NTX2 = 1 if statements are entered without newlines for\r
+                                       // multiple lines\r
+                                       raFile.writeBytes(PAD + VAR + "ANS[0] = " + HA + "*(");\r
+                                       for (I = 1; I <= NTX2; I++) {\r
+                                               int index = TXT2[I - 1].indexOf("ui");\r
+                                               String realString = null;\r
+                                               if (index == -1) {\r
+                                                       realString = TXT2[I - 1];\r
+                                               } else {\r
+                                                       realString = TXT2[I - 1].substring(0, index);\r
+                                               }\r
+                                               if ((index == -1) || (index > 0)) {\r
+                                                       raFile.writeBytes(realString);\r
+                                               }\r
+                                               if (I == NTX2) {\r
+                                                       raFile.writeBytes(");\n");\r
+                                               }\r
                                        }\r
                                }\r
-                               raFile.writeBytes("      " + VAR + "ANS[1] = " + HA + "*(");\r
+                               boolean uifound = false;\r
+                               for (I = 1; I <= NTX2; I++) {\r
+                                   if (TXT2[I-1].indexOf("ui") >= 0) {\r
+                                       uifound = true;\r
+                                   }\r
+                               }\r
+                               if (!uifound) {\r
+                                   raFile.writeBytes(PAD + VAR + "ANS[1] = 0.0;\n");\r
+                               }\r
+                               else {\r
                                // NTX2 = 1 if statements are entered without newlines for\r
                                // multiple lines\r
-                               for (I = 1; I <= NTX2; I++) {\r
-                                       int index = TXT2[I - 1].indexOf("ui");\r
-                                       String imagString = null;\r
-                                       if ((index >= 0) && (index + 2 < TXT2[I - 1].length())) {\r
-                                               imagString = TXT2[I - 1].substring(index + 2);\r
-                                               raFile.writeBytes(imagString);\r
-                                       }\r
-                                       if (I == NTX2) {\r
-                                               raFile.writeBytes(");\n");\r
+                                       raFile.writeBytes(PAD + VAR + "ANS[1] = " + HA + "*(");\r
+                                       for (I = 1; I <= NTX2; I++) {\r
+                                               int index = TXT2[I - 1].indexOf("ui");\r
+                                               String imagString = null;\r
+                                               if ((index >= 0) && (index + 2 < TXT2[I - 1].length())) {\r
+                                                       imagString = TXT2[I - 1].substring(index + 2);\r
+                                                       raFile.writeBytes(imagString);\r
+                                               }\r
+                                               if (I == NTX2) {\r
+                                                       raFile.writeBytes(");\n");\r
+                                               }\r
                                        }\r
                                }\r
                                raFile.writeBytes("//\n");\r
@@ -1868,22 +1950,109 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                MD = 0.5 * (RGM[1] + RGM[0]);\r
                                HA = 0.5 * (RGM[1] - RGM[0]);\r
                                raFile.writeBytes("//\n");\r
-                               raFile.writeBytes("      T = " + MD + "+" + CHTT + "*" + "(" + HA + ");\n");\r
-                               raFile.writeBytes("      ZRAD = ");\r
+                               raFile.writeBytes(PAD + "T[0] = " + MD + "+" + CHTT + "[0]*(" + HA + ");\n");\r
+                               raFile.writeBytes(PAD + "T[1] = " + CHTT + "[1]*(" + HA + ");\n");\r
+                               if (TXT1[0].indexOf("ui") == 0) {\r
+                                   raFile.writeBytes(PAD + "ZRAD[0] = 0.0;\n");\r
+                               }\r
+                               else {\r
+                                       // NTX1 = 1 if statements are entered without newlines for\r
+                                       // multiple lines\r
+                                       raFile.writeBytes(PAD + "ZRAD[0] = ");\r
+                                       for (I = 1; I <= NTX1; I++) {\r
+                                               int index = TXT1[I - 1].indexOf("ui");\r
+                                               String realString = null;\r
+                                               if (index == -1) {\r
+                                                       realString = TXT1[I - 1];\r
+                                               } else {\r
+                                                       realString = TXT1[I - 1].substring(0, index);\r
+                                               }\r
+                                               if ((index == -1) || (index > 0)) {\r
+                                                       raFile.writeBytes(realString);\r
+                                               }\r
+                                               if (I == NTX1) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                               }\r
+                                       }\r
+                               }\r
+                               boolean uifound = false;\r
                                for (I = 1; I <= NTX1; I++) {\r
-                                       raFile.writeBytes(TXT1[I - 1]);\r
+                                   if (TXT1[I-1].indexOf("ui") >= 0) {\r
+                                       uifound = true;\r
+                                   }\r
+                               }\r
+                               if (!uifound) {\r
+                                   raFile.writeBytes(PAD + "ZRAD[1] = 0.0;\n");\r
+                               }\r
+                               else {\r
+                                       // NTX1 = 1 if statements are entered without newlines for\r
+                                       // multiple lines\r
+                                       raFile.writeBytes(PAD + "ZRAD[1] = ");\r
+                                       for (I = 1; I <= NTX1; I++) {\r
+                                               int index = TXT1[I - 1].indexOf("ui");\r
+                                               String imagString = null;\r
+                                               if ((index >= 0) && (index + 2 < TXT1[I - 1].length())) {\r
+                                                       imagString = TXT1[I - 1].substring(index + 2);\r
+                                                       raFile.writeBytes(imagString);\r
+                                               }\r
+                                               if (I == NTX1) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                               }\r
+                                       }\r
+                               }\r
+                               if (TXT2[0].indexOf("ui") == 0) {\r
+                                   raFile.writeBytes(PAD + "ZDER[0] = 0.0;\n");\r
                                }\r
-                               raFile.writeBytes(";\n");\r
-                               raFile.writeBytes("      ZDER = ");\r
+                               else {\r
+                                       // NTX2 = 1 if statements are entered without newlines for\r
+                                       // multiple lines\r
+                                       raFile.writeBytes(PAD + "ZDER[0] = ");\r
+                                       for (I = 1; I <= NTX2; I++) {\r
+                                               int index = TXT2[I - 1].indexOf("ui");\r
+                                               String realString = null;\r
+                                               if (index == -1) {\r
+                                                       realString = TXT2[I - 1];\r
+                                               } else {\r
+                                                       realString = TXT2[I - 1].substring(0, index);\r
+                                               }\r
+                                               if ((index == -1) || (index > 0)) {\r
+                                                       raFile.writeBytes(realString);\r
+                                               }\r
+                                               if (I == NTX2) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                               }\r
+                                       }\r
+                               }\r
+                               uifound = false;\r
                                for (I = 1; I <= NTX2; I++) {\r
-                                       raFile.writeBytes(TXT2[I - 1]);\r
+                                   if (TXT2[I-1].indexOf("ui") >= 0) {\r
+                                       uifound = true;\r
+                                   }\r
+                               }\r
+                               if (!uifound) {\r
+                                   raFile.writeBytes(PAD + "ZDER[1] = 0.0;\n");\r
+                               }\r
+                               else {\r
+                                       // NTX2 = 1 if statements are entered without newlines for\r
+                                       // multiple lines\r
+                                       raFile.writeBytes(PAD + "ZDER[1] = ");\r
+                                       for (I = 1; I <= NTX2; I++) {\r
+                                               int index = TXT2[I - 1].indexOf("ui");\r
+                                               String imagString = null;\r
+                                               if ((index >= 0) && (index + 2 < TXT2[I - 1].length())) {\r
+                                                       imagString = TXT2[I - 1].substring(index + 2);\r
+                                                       raFile.writeBytes(imagString);\r
+                                               }\r
+                                               if (I == NTX2) {\r
+                                                       raFile.writeBytes(";\n");\r
+                                               }\r
+                                       }\r
                                }\r
-                               raFile.writeBytes(";\n");\r
-                               raFile.writeBytes("      " + VAR + "ANS[0] = (ZDER * Math.cos(T) - ZRAD * Math.sin(T))*(" + HA + ");\n");\r
-                               raFile.writeBytes("      " + VAR + "ANS[1] = (ZDER * Math.sin(T) + ZRAD * Math.cos(T))*(" + HA + ");\n");\r
+                               raFile.writeBytes(PAD + VAR + "ANS[0] = ((ZDER[0] - ZRAD[1])* Math.cos(T[0]) - (ZRAD[0] + ZDER[1])* Math.sin(T[0]))*Math.exp(-T[1])*(" + HA + ");\n");\r
+                               raFile.writeBytes(PAD + VAR + "ANS[1] = ((ZDER[0] - ZRAD[1])* Math.sin(T[0]) + (ZRAD[0] + ZDER[1])* Math.cos(T[0]))*Math.exp(-T[1])*(" + HA + ");\n");\r
                                raFile.writeBytes("//\n");\r
                        } // else\r
-                       raFile.writeBytes("return " + VAR + "ANS;\n");\r
+                       raFile.writeBytes(PAD + "return " + VAR + "ANS;\n");\r
                } // try\r
                catch (IOException e) {\r
                        MipavUtil.displayError("IOException " + e + " in PTFUN2");\r