/* */ /* 'this' script traces is a D R A F T, do play as you please B U T if you see faults (especially on the (it's not) OO side), then do think about contacting me.. E S P E C I A L L Y if you're looking for a 'scripting'/3D/Animation project for School/Uni'.. I've got other 'fish' on my mind, so 'clean up' & 'development' associates will be welcomed.. & yes, the address is a genuine one..... & yes, Zwolf/Zwo:lf is a nomDePlume (or nomDejEdit)... */ import java.math.*; curvesNameList = new BList(new String [] { "Astroid", "Cardioid", "Catenary", "Cayley's Sextic", "Cissoid of Diocles", "Cochleoid", "Conchoid", "Conchoid of de Sluze", "Cycloid", "Devil's Curve", "Double Folium", "Eight Curve", "Ellipse", "Epicycloid", "Epitrochoid", "Equiangular Spiral", "Fermat's Spiral", "Folium", "Folium of Descartes", "Freeth's Nephroid", "Frequency Curve", "Hyperbola", "Hyperbolic Spiral", "Hypocycloid", "Hypotrochoid", "Involute of a Circle", "Kampyle of Eudoxus", "Kappa Curve", "Lame Curves", "Lemniscate of Bernoulli", "Limacon of Pascal", "Lissajous Curves", "Lituus", "Neile's SemiCubical Parabola", "Nephroid", "Parabola", "PearShaped Quartic", "Plateau Curves", "Pursuit Curve", "Quadratrix of Hippias", "Rhodonea Curves", "Right Strophoid", "Serpentine", "Sinusoidal Spirals", "Spiral of Archimedes", "Talbot's Curve", "Tractrix", "Tricuspoid", "Trident of Newton", "Trifolium", "Trisectrix of Maclaurin", "Tschirnhaus' Cubic", "Watt's Curve", "Witch of Agnesi" }); curvesNameList.setPreferredVisibleRows(10); newOuijiButton = new BButton("Select!"); newOuijiButton.addEventLink(CommandEvent.class, new Runnable() { void run() { private int curveNdx = curveSelection(); private String detectedCurveTyp = curveTypeDetection(); private String selectedCurveName = getSelectedCurveName(); private int gotCurvePonentDialogType = getCurvePonentDialogType(detectedCurveTyp); makeCurvePonentDialog(selectedCurveName, curveNdx, detectedCurveTyp, gotCurvePonentDialogType); } }, "run"); static int curveSelection(){ private int curveSelected = curvesNameList.getSelectedIndex(); return curveSelected; } static String getSelectedCurveName(){ private String selectedCurveName = curvesNameList.getSelectedValue(); return selectedCurveName; } static String curveTypeDetection(){ private String curveName = curvesNameList.getSelectedValue(); private int curveNdx = curvesNameList.getSelectedIndex(); private String detectEdCurveType; // I will make the following 114 lines a separate method when I get things finished (finishing on 'line 239').... // What follows is a draft way of detecting the Curve/Trajectory 'type', I've tried 'futureproofing' the technique.. // ..by providing for the addition of new Curve/Trajectories; hence the 'process of verification': private int cNLIC = curvesNameList.getItemCount(); if (cNLIC != 54){ print("The Curve/Trajectory Script requires re-working (A); mail: kevinzwolf via users.sourceforge.net"); // ...here if we find that a new Curve/Trajectory was added ('half' added) then we request contact & close up shop... return; } else{ // ...else we continue (yes, I am sure as I write this that this is a job for try, catch & finally..)... private String[] curvesNameArray = new String[] { "Astroid", "Cardioid", "Catenary", "Cayley's Sextic", "Cissoid of Diocles", "Cochleoid", "Conchoid", "Conchoid of de Sluze", "Cycloid", "Devil's Curve", "Double Folium", "Eight Curve", "Ellipse", "Epicycloid", "Epitrochoid", "Equiangular Spiral", "Fermat's Spiral", "Folium", "Folium of Descartes", "Freeth's Nephroid", "Frequency Curve", "Hyperbola", "Hyperbolic Spiral", "Hypocycloid", "Hypotrochoid", "Involute of a Circle", "Kampyle of Eudoxus", "Kappa Curve", "Lame Curves", "Lemniscate of Bernoulli", "Limacon of Pascal", "Lissajous Curves", "Lituus", "Neile's SemiCubical Parabola", "Nephroid", "Parabola", "PearShaped Quartic", "Plateau Curves", "Pursuit Curve", "Quadratrix of Hippias", "Rhodonea Curves", "Right Strophoid", "Serpentine", "Sinusoidal Spirals", "Spiral of Archimedes", "Talbot's Curve", "Tractrix", "Tricuspoid", "Trident of Newton", "Trifolium", "Trisectrix of Maclaurin", "Tschirnhaus' Cubic", "Watt's Curve", "Witch of Agnesi" }; private String curveNameCheckEd = curvesNameArray[curveNdx]; private boolean curveNameOKd = curveName.equals(curveNameCheckEd); // ..here we are providing for any juggling 'round of the Curve/Trajectory List... if (curveNameOKd == true){ // ..if we find all is OK-ed, then we proceed...(safely, we hope...)... private String[] curveTypesArray = new String[] { "a", "a", "a", "a", "a", "a", "ba", "ka", "ha", "a", "a", "a", "ba", "ba", "cba", "ba", "a", "ba", "a", "a", "F", "ba", "a", "ba", "cba", "a", "ba", "a", "ba", "a", "ba", "ncba", "a", "a", "a", "cba", "ba", "nma", "c", "a", "ka", "a", "ba", "pa", "a", "fba", "T", "a", "fedc", "a", "a", "a", "cba", "a" }; detectEdCurveType = curveTypesArray[curveNdx]; }else{ print("The Curve/Trajectory Script requires re-working (J); mail: kevinzwolf via users.sourceforge.net"); return; } // ...same 'chimpanzee logic' works here... stage by stage verification.... } // ...closing that big 'else' that began after we established that the list the user sees is the 'right' length.. // ...I will finish that method here.. (began 'line 125')... return detectEdCurveType; } static int getCurvePonentDialogType(dlivrdCurveType){ private String soughtCurvePonentNdy = dlivrdCurveType; private int ndyLength = soughtCurvePonentNdy.length(); return ndyLength; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Mathematics 'lowerCaseMethods' Section static double sinh(double tAngle) { return ((Math.exp(tAngle) - Math.exp(-tAngle))/2); } static double cosh(double tAngle) { return ((Math.exp(tAngle) + Math.exp(-tAngle))/2); } static double tanh(double tAngle) { return (sinh(tAngle)/cosh(tAngle)); } static double sec(double tAngle) { return 1/Math.cos(tAngle); } static double cosec(double tAngle) { return 1/Math.sin(tAngle); } static double cotan(double tAngle) { return 1/Math.tan(tAngle); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ..a 'sign' Method.. static double sign(double dlivrdValue) { if (dlivrdValue > 0) { return 1;} else {if (dlivrdValue < 0) { return -1;} else { return 0;}} } // ..the 'traces' Methods public static double[] astroidM(dlivrdItrns, dlivrdPrec, dlivrdAngle, dlivrdA) { private int itrns = dlivrdItrns; private int ndx = itrns*2; private double[] myXYArray = new double[ndx]; private float deltaTA = dlivrdPrec; private double tAngle = dlivrdAngle; private float a = dlivrdA; private double myX = 0; private double myY = 0; for (int i=0; i= 2){vFT = valueFieldTwo.getValue();} if(ouiJiCTDNdx >= 3){vF3 = valueFieldThr.getValue();} if(ouiJiCTDNdx == 4){vF4 = valueFieldFou.getValue();} fXVF = theFirstXValueField.getValue(); fYVF = theFirstYValueField.getValue(); fZVF = theFirstZValueField.getValue(); dZVF = theDeltaZValueField.getValue(); doubleIVF = iVF*2; double[] reTurnEdArray = new double[doubleIVF]; // ...now this must become reTurnEdArray = blahMethod(ouiTCTNdx, parameters....); if(ouiJiCTDNdx == banana){blah.. & cetera... switch(ouiJiCTNdx){ case 0: reTurnEdArray = astroidM(iVF, pVF, tAVF, vFO); break; case 1: reTurnEdArray = cardioidM(iVF, pVF, tAVF, vFO); break; case 2: reTurnEdArray = catenaryM(iVF, pVF, tAVF, vFO); break; case 3: reTurnEdArray = cayleysSexticM(iVF, pVF, tAVF, vFO); break; case 4: reTurnEdArray = cissoidOfDioclesM(iVF, pVF, tAVF, vFO); break; case 5: reTurnEdArray = cochleoidM(iVF, pVF, tAVF, vFO); break; case 6: reTurnEdArray = conchoidM(iVF, pVF, tAVF, vFO, vFT); break; case 7: reTurnEdArray = conchoidOfDeSluzeM(iVF, pVF, tAVF, vFO, vFT); break; case 8: reTurnEdArray = cycloidM(iVF, pVF, tAVF, vFO, vFT); break; case 9: reTurnEdArray = devilsCurveM(iVF, pVF, tAVF, vFO); break; case 10: reTurnEdArray = doubleFoliumM(iVF, pVF, tAVF, vFO); break; case 11: reTurnEdArray = eightCurveM(iVF, pVF, tAVF, vFO); break; case 12: reTurnEdArray = ellipseM(iVF, pVF, tAVF, vFO, vFT); break; case 13: reTurnEdArray = epicycloidM(iVF, pVF, tAVF, vFO, vFT); break; case 14: reTurnEdArray = epitrochoidM(iVF, pVF, tAVF, vFO, vFT, vF3); break; case 15: reTurnEdArray = equiangularSpiralM(iVF, pVF, tAVF, vFO, vFT); break; case 16: reTurnEdArray = fermatsSpiralM(iVF, pVF, tAVF, vFO); break; case 17: reTurnEdArray = foliumM(iVF, pVF, tAVF, vFO, vFT); break; case 18: reTurnEdArray = foliumOfDescartesM(iVF, pVF, tAVF, vFO); break; case 19: reTurnEdArray = freethsNephroidM(iVF, pVF, tAVF, vFO); break; case 20: reTurnEdArray = frequencyCurveM(iVF, pVF, tAVF, vFO); break; //fDummyVar case 21: reTurnEdArray = hyperbolaM(iVF, pVF, tAVF, vFO, vFT); break; case 22: reTurnEdArray = hyperbolicSpiralM(iVF, pVF, tAVF, vFO); break; case 23: reTurnEdArray = hypocycloidM(iVF, pVF, tAVF, vFO, vFT); break; case 24: reTurnEdArray = hypotrochoidM(iVF, pVF, tAVF, vFO, vFT, vF3); break; case 25: reTurnEdArray = envoluteOfACircleM(iVF, pVF, tAVF, vFO); break; case 26: reTurnEdArray = kampyleOfEudoxusM(iVF, pVF, tAVF, vFO, vFT); break; case 27: reTurnEdArray = kappaCurveM(iVF, pVF, tAVF, vFO); break; case 28: reTurnEdArray = lameHaCurvesM(iVF, pVF, tAVF, vFO, vFT); break; case 29: reTurnEdArray = lemniscateOfBernoulliM(iVF, pVF, tAVF, vFO); break; case 30: reTurnEdArray = limaconOfPascalM(iVF, pVF, tAVF, vFO, vFT); break; case 31: reTurnEdArray = lissajousCurvesM(iVF, pVF, tAVF, vFO, vFT, vF3, vF4); break; case 32: reTurnEdArray = lituusM(iVF, pVF, tAVF, vFO); break; case 33: reTurnEdArray = neilesSemiCubicalParabolaM(iVF, pVF, tAVF, vFO); break; case 34: reTurnEdArray = nephroidM(iVF, pVF, tAVF, vFO); break; case 35: reTurnEdArray = parabolaM(iVF, pVF, tAVF, vFO, vFT, vF3); break; case 36: reTurnEdArray = pearShapedQuarticM(iVF, pVF, tAVF, vFO, vFT); break; case 37: reTurnEdArray = plateauCurvesM(iVF, pVF, tAVF, vFO, vFT, vF3); break; case 38: reTurnEdArray = pursuitCurveM(iVF, pVF, tAVF, vFO); break; case 39: reTurnEdArray = quadratrixOfHippiasM(iVF, pVF, tAVF, vFO); break; case 40: reTurnEdArray = rhodoneaCurvesM(iVF, pVF, tAVF, vFO, vFT); break; case 41: reTurnEdArray = rightStrophoidM(iVF, pVF, tAVF, vFO); break; case 42: reTurnEdArray = serpentineM(iVF, pVF, tAVF, vFO, vFT); break; case 43: reTurnEdArray = sinusoidalSpiralsM(iVF, pVF, tAVF, vFO, vFT); break; case 44: reTurnEdArray = spiralOfArchimedesM(iVF, pVF, tAVF, vFO); break; case 45: reTurnEdArray = talbotsCurveM(iVF, pVF, tAVF, vFO, vFT, vF3); break; case 46: reTurnEdArray = tractrixM(iVF, pVF, tAVF, vFO); break; //tDummyVar case 47: reTurnEdArray = tricuspoidM(iVF, pVF, tAVF, vFO); break; case 48: reTurnEdArray = nsTridentM(iVF, pVF, tAVF, vFO, vFT, vF3, vF4); break; case 49: reTurnEdArray = trifoliumM(iVF, pVF, tAVF, vFO); break; case 50: reTurnEdArray = trisectrixOfMacLaurinM(iVF, pVF, tAVF, vFO); break; case 51: reTurnEdArray = tschirnhausCubicM(iVF, pVF, tAVF, vFO); break; case 52: reTurnEdArray = wattsCurveM(iVF, pVF, tAVF, vFO, vFT, vF3); break; case 53: reTurnEdArray = witchOfAgnesiM(iVF, pVF, tAVF, vFO); break; // I've done the check here...& then set up vF4s as I said I'd do one day... } // ...ugly, ugly, ugly.... (the 'switch' ^ there)... print("Traced!: precision = " + pVF + ", number of points = " + iVF + "..& beginning angle = " + tAVF); print("\n"); // ...& now for 'parenting/bundling' large number of new additions on the scene/window Objects Panel... parenTrace = new NullObject(); parenTracEnformation = new ObjectInfo(parenTrace, new CoordinateSystem(), ouiJiName); window.addObject(parenTracEnformation, null); // ...& finished 'setting up'... see line 2770... ////////////////////////////////////////////////////////////////////////////// int ijk = doubleIVF - 1; int iTh = 1; float xCoOrd = fXVF; float yCoOrd = fYVF; float zCoOrd = fZVF; float zVal = dZVF; // ...development of 'neuron' code: Vec3[] trArray = new Vec3[iVF]; float[] smoothIness = new float[iVF]; // ...see tracEdRawNeuron... while(ijk > 0){ private double theX = reTurnEdArray[ijk - 1] - reTurnEdArray[doubleIVF - 2] + xCoOrd; private double theY = reTurnEdArray[ijk] - reTurnEdArray[doubleIVF - 1] + yCoOrd; private float theZ = zCoOrd; // give us some spheres (that'll show up on 3D)! sphere = new Sphere(0.1, 0.1, 0.1); // ...make the preceding an 'option'... not only size... but the 'simple'... flipXYZ.getState()? pos = new Vec3(theX, theY, theZ): flipXZY.getState()? pos = new Vec3(theX, theZ, theY): flipYXZ.getState()? pos = new Vec3(theY, theX, theZ): flipYZX.getState()? pos = new Vec3(theY, theZ, theX): flipZXY.getState()? pos = new Vec3(theZ, theX, theY): flipZYX.getState()? pos = new Vec3(theZ, theY, theX): print("..ooops, error(F)!; mail: kevinzwolf via users.sourceforge.net.."); print(iTh + ": " + pos + "\n"); ijk--; ijk--; zCoOrd = zCoOrd + zVal; private String objectTitle = "the " + iTh + "th traceObject"; iTh++; // ...line 2713, add some lines for ensuring the 'parenting/bundling' works...////////////////////////////////////////////////// objectCoOrdinateSystem = new CoordinateSystem(pos, 0, 0, 0); childTraceData = new ObjectInfo(sphere, objectCoOrdinateSystem, objectTitle); parenTracEnformation.addChild(childTraceData, parenTracEnformation.children.length); window.addObject(childTraceData, null); // ...& once we do a window.rebuildItemList() just after this loop, then we are done (& possibly dust(er)ed...)! trArray[iTh - 2] = pos; smoothIness[iTh - 2] = 0; // ...preceding line adds another pos for use by tracEdRawNeuron } window.rebuildItemList(); tracEdRawNeuron = new Curve(trArray, smoothIness, Mesh.APPROXIMATING, false); private String neuroName = ouiJiName + " / neuroneTrace"; window.addObject(tracEdRawNeuron, new CoordinateSystem(), neuroName, null); } return; }, "run"); if (ouiJiCTDNdx == 1){ if (vFOff.equals("off")){ ouiJi1 = new Widget[]{precisionValueField, iterationsValueField, theAngleValueField, theFirstXValueField, theFirstYValueField, theFirstZValueField, theDeltaZValueField, flipGridCon, ouiTBu}; // labels for those components... ouiSt1 = new String[]{"Precision", "Number of Points", "Beginning Angle", "begin X @", "begin Y @", "begin Z @", "delta Z", "map XYZ >>>", null};} // 'F' (frequency curve) & 'T' (tractrix) are (actually) constant-less... else{ ouiJi1 = new Widget[]{precisionValueField, iterationsValueField, theAngleValueField, valueFieldOne, theFirstXValueField, theFirstYValueField, theFirstZValueField, theDeltaZValueField, flipGridCon, ouiTBu}; // labels for those components... ouiSt1 = new String[]{"Precision", "Number of Points", "Beginning Angle", ouiJiCurT, "begin X @", "begin Y @", "begin Z @", "delta Z", "map XYZ >>>", null}; } ouiCD1 = new ComponentsDialog(window, ouiJiName, ouiJi1, ouiSt1); } else if (ouiJiCTDNdx == 2){ ouiJi2 = new Widget[]{precisionValueField, iterationsValueField, theAngleValueField, valueFieldOne, valueFieldTwo, theFirstXValueField, theFirstYValueField, theFirstZValueField, theDeltaZValueField, flipGridCon, ouiTBu}; // labels for those components... ouiSt2 = new String[]{"Precision", "Number of Points", "Beginning Angle", vFOName, vFTName, "begin X @", "begin Y @", "begin Z @", "delta Z", "map XYZ >>>", null}; ouiCD2 = new ComponentsDialog(window, ouiJiName, ouiJi2, ouiSt2); } else if (ouiJiCTDNdx == 3){ ouiJi3 = new Widget[]{precisionValueField, iterationsValueField, theAngleValueField, valueFieldOne, valueFieldTwo, valueFieldThr, theFirstXValueField, theFirstYValueField, theFirstZValueField, theDeltaZValueField, flipGridCon, ouiTBu}; // labels for those components... ouiSt3 = new String[]{"Precision", "Number of Points", "Beginning Angle", vFOName, vFTName, vF3Name, "begin X @", "begin Y @", "begin Z @", "delta Z", "map XYZ >>>", null}; ouiCD3 = new ComponentsDialog(window, ouiJiName, ouiJi3, ouiSt3); }else if (ouiJiCTDNdx == 4){ ouiJi4 = new Widget[]{precisionValueField, iterationsValueField, theAngleValueField, valueFieldOne, valueFieldTwo, valueFieldThr, valueFieldFou, theFirstXValueField, theFirstYValueField, theFirstZValueField, theDeltaZValueField, flipGridCon, ouiTBu}; // labels for those components... ouiSt4 = new String[]{"Precision", "Number of Points", "Beginning Angle", vFOName, vFTName, vF3Name, vF4Name, "begin X @", "begin Y @", "begin Z @", "delta Z", "map XYZ >>>", null}; ouiCD4 = new ComponentsDialog(window, ouiJiName, ouiJi4, ouiSt4); } // ...end 'if's... return; // ...does I 'return' here? I s'pose so..... as Joe Byrne 'sez'; if not... } // end of makeCurvePonentDialogCurveTypeDialog Section.... // ...the opening ComponentDialog.... ouiJiCurve = new Widget[]{UIUtilities.createScrollingList(curvesNameList), newOuijiButton}; ouiStCurve = new String[]{null, null}; private String tracesString = "TRajectory & CurvE Script"; ouiJiCurveDialog = new ComponentsDialog(window, tracesString, ouiJiCurve, ouiStCurve); // ...wholly holy cow! ~ ....& it's done...