Project Parameterization, rocker demo

 From: bemfarmer 13 Aug 2014  (1 of 14)
 Hi Michael. If you have a little time, given Moi 3 finalization, this is a Request for help scripting "Project" factory. The Curve Project command "Projects a curve onto a surface or solid." For a 2D Top View, it will also project a point on the x-axis, onto a curve, (or curves), using point direction, Inputs 3 and 4. I have been trying very hard to script the Project factory, to get the y values of a 2d curve, using progressive x values, without very much success. I am using the 2D graph of a curve, in Top View, where x = si, ranges from 0 to 2PI. The curve is attached as file KappaVersusS11.3dm. (There is also a tau curve.) _FrenetKTCurveIncompleteDraft script is also attached, (which does not crash Moi, but has "assert failed") The BAD subroutine function attempting to use "Project" is "function EvalKappaTau( curve, si )" (A Demo script is attached for "Rudy's Rocker": FrenetKTCurveRocker, which works with kappa and tau equations.) (These two curves represent curvature and torsion for a particular Moebius strip centerline.) The green kappa curve is selected by the user, so it is an objectList, and Input 1. (EDIT, FALSE statement) The green kappa curve has only one y value for each x value. The y values of the curve represent kappa values, the curvature of a frenet frame, where the x value si also represents the arc length of another curve to be created. In the Project factory, Input 0, the BaseObject, must be an ObjectList of a point. Point (si, 0, 0) will be used to create the point object, to be projected in the vertical direction, to obtain point (si, y, 0). This code to create the BaseObject works, per testing with modified Moi Project.js: /code var x = si; // x-axis value, used 3 times per evaluation. var y = 0.0; // used twice, for point to Project, and start direction. var y1 = 1.0; // for Project direction. var z = 0.0; var xPt = moi.vectorMath.createPoint( x, y, z ) var siPt; var siPtobjList = moi.geometryDatabase.createObjectList(); var pointfactory = moi.command.createFactory( 'point' ); pointfactory.setInput( 0, xPt ); siPt = pointfactory.calculate(); moi.geometryDatabase.addObjects( siPt ); siPtobjList.addObject( siPt.item(0) ); // Object Input 0 of Project factory. // The above block of code produces the correct ObjectList Input of Project factory, in my opinion, per testing. \code For the direction, The basept, or start point is: var basept = moi.vectorMath.createPoint( si, 0.0, 0.0 ); Input 3. >>> This does not seem to work. The endpt or endDir is: var endDir = moi.vectorMath.createPoint( si, 1.0, 0.0 ); Input 4. >>> This does not seem to work. Input 2 is Mode, and is a string 'direction', or is it direction? >>> Not sure if this is correct. Input 5 involves 'deleteinputs', (?) Input 6 involves cplane, and so should not be needed. (?) After the Project factory produces (some type of) point, ( si, y, 0.0 ), I need to extract the y value, as a number, a value for kappa. (Similarly for tau.) If I cannot get the Project scripting to work, I can probably use line segments, extend, and intersection. I'll still have to extract the y value from the intersection point. Thank you, Brian EDIT: bad scripts deleted, will post corrected updates, hopefully. EDITED: 14 Aug 2014 by BEMFARMER Attachments:

 From: Michael Gibson 14 Aug 2014  (2 of 14)
 6860.2 In reply to 6860.1 Hi Brian, the assert is coming from the Interpolated curve factory, maybe something like stacked up points in it, like duplicated points maybe... Taking a look at why project is not working for you. - Michael

 From: Michael Gibson 14 Aug 2014  (3 of 14)
 6860.3 In reply to 6860.1 Hi Brian, project's not working because input 1, the target objects - that needs to be an object list not just a single object. So this line #122 here:     projectfactory.setInput( 1, curve ); Replace it with something like this:     var targetlist = moi.geometryDatabase.createObjectList();     targetlist.addObject( curve );     projectfactory.setInput( 1, targetlist ); That then looks like it will get the project part working. Then there's another assert which looks like it's about a call to moi.geometryDatabase.addObjects() with an object that's actually in the database already, so maybe some extra call to that somewhere in there. Hope this helps! - Michael

 From: bemfarmer 14 Aug 2014  (4 of 14)
 6860.4 In reply to 6860.3 Thank you very much Michael. :-) Hopefully that will be a wrap... and a wrap with objectlist, encountered previously (pipe command). So, when I did: var kappacurve = objectpicker.objects.item(0);, kappacurve became a single object, NO LONGER an objectlist, and must be re-wrapped. This would not have happened with individual picks...(I think). I think the asserts should go away with the correction. - Brian

 From: bemfarmer 14 Aug 2014  (5 of 14)
 6860.5 In reply to 6860.3 Made some progress. There are still some problems. The script is confusing the two curves. It prefers to use the bottom one. :-) Cannot extract the y value of the points. /code projectfactory.update(); var ktpointobj = projectfactory.getCreatedObjects(); var ktpoint = ktpointobj.item(0); // var ktpointlist = projectfactory.calculate(); // var ktpoint = ktpointlist.item(0); // moi.geometryDatabase.addObject( ktpoint ); //alert ("ktpoint.x = " + ktpoint.x + "\nktpoint.y = " + ktpoint.y + "\nktpoint.z = " + ktpoint.z ); var kORtValue = ktpoint.y; return kORtValue; /code Still getting asserts in two patterns associated with for loops. 9 = 1+4+4, 4, 4, 4 First loop has no assert, so the asserts are probably caused by failure to extract y values. (Guess)

 From: Michael Gibson 14 Aug 2014  (6 of 14)
 6860.6 In reply to 6860.5 Hi Brian, > Cannot extract the y value of the points. > > /code > projectfactory.update(); > var ktpointobj = projectfactory.getCreatedObjects(); > var ktpoint = ktpointobj.item(0); So here ktpoint is a "point object" which has the standard geometry object properties like style, hidden, name, etc... then in addition to that set of common properties that curves and solids also have, there is an additional .pt property on it that will give back a "data structure point" that has the x,y,z values on it. So to get the x,y,z values you need to get at the .pt property first, like: ktpoint.pt.y - Michael

 From: bemfarmer 14 Aug 2014  (7 of 14)
 6860.7 In reply to 6860.6 Thank you Michael. Adding .pt worked to get the .y value. The Asserts went away as well. Also added: curves.sortBySelectionOrder(); from lineweb, to clear up which curve is which. I am not sure about where and how objectpicker.min = objectpicker.max = 2; fits in. What is the difference between objectpicker.allowCurves(); and objectpicker.allowStandaloneCurves(); ? The script is working, in some fashion, but may still need some work tonight. It is slow in .js :-) - Brian

 From: Michael Gibson 14 Aug 2014  (8 of 14)
 6860.8 In reply to 6860.7 Hi Brian, > I am not sure about where and how objectpicker.min = objectpicker.max = 2; fits in. That will make the object picker trigger it's "finished" event immediately after 2 curves are selected, like as soon as the second curve is clicked on, rather than the regular selection path where it waits until the user pushes "Done" (or right-clicks in a viewport as a shortcut for "Done") before the "finished" event is triggered. > What is the difference between objectpicker.allowCurves(); > and objectpicker.allowStandaloneCurves(); ? allowCurves() means allow any kind of curve including edge curves. If you instead do allowStandaloneCurves() it will mean edge curves won't be allowed for the pick. - Michael

 From: bemfarmer 15 Aug 2014  (9 of 14)
 Here is my latest FrenetKTCurve script, which generates a 3D space curve from the 2D curve graphs of Curvature Kappa, and Torsion, Tau. Thanks again to Michael for much help and explanations of scripting. Since the script is probably not bug proof, it should not be used with unsaved or valuable work. A demo curvature and torsion graph of Rudy's Rocker is included. The PI length should be set to 4.0. The user interface could use an Update button. The reason for doing the script was to produce a Moebius strip, which it almost will do. The graph of Kappa and Tau is approximate. The graph is included as KappaVersusS12.3dm. Load it into Moi, then run the script. The PI length should be 1.0, as the second half of the curve comes out wrong. Kappa of zero can be a problem. The second mirror of the half loft surface almost closes to a Moebius strip. The trouble with the Frenet frame is getting the curves to close. A Moebius strip centerline curve, based upon the physics of real materials, has been calculated by E.L. Starostin, and G.H.M. van der Heijden, defined by Curvature (kappa), and Torsion (tau). The mathematics is advanced, and DAE equations must be solved. http://www.ucl.ac.uk/~ucesgvd/moebius.pdf (copy to browser) http://www.homepages.ucl.ac.uk/~ucesgvd/moebius_suppl.pdf http://arxiv.org/abs/0905.1880 http://arxiv.org/abs/0804.0419 http://arxiv.org/abs/0807.0377 http://onlinelibrary.wiley.com/doi/10.1002/pamm.200700858/pdf This script does NOT solve the DAE equations to determine the Kappa and Tau curves for a particular width of a Moebius strip of length 2*PI. Nor does it do a 3-fold Moebius strip. DAE solving may be attempted later. Maple or Mathematica can do it with Runge-Kutta-Fehlberg45. Solving the DAE equations should produce Kappa and Tau numbers to get a closed curve. Other Kappa and Tau graphs can be used. The PI length should not be greater than the x values of the curves. The graphs must satisfy the vertical line test, as there can be only one y value for an x value. A trial of curves which violate this rule did not crash Moi, but in one case the new curve did not finish. I want to be able to do a 3-fold Moebius. The papers tell how to do so, but they leave out much information about the actual solving of the DAE equations. The number of points should be 100 or 200, for a more accurate curve, which takes some time. - Brian EDITED: 16 Aug 2014 by BEMFARMER Attachments:

 From: Mike (MGG942) 16 Aug 2014  (10 of 14)
 6860.10 In reply to 6860.9 Brian, Would you mind explaining in a little more detail how to use the two .3dm files? Thanks, Mike.

 From: bemfarmer 16 Aug 2014  (11 of 14)
 6860.11 In reply to 6860.10 Hi Mike 1. Load the .3dm file of a 2D pair of curves into Moi. Front view is good. 2. Start the script. I am using Max's custom UI, having run short of shortcut keys :-) 3. Select the upper curve as Kappa curvature. Select the lower curve as Tau Torsion. Selection in reverse will create a different curve. 4. Adjust the values appropriately. PI length is the maximum x value of the 2D curves, and also will be the arclength of the new 3D curve, Currently the script starts running at x=0. numpoints +1 is the the number of points used to create the 3D curve and lines. The start point accounts for the +1. The Project command is used about 2 X 8 times per point, to get Kappa and Tau. Checkboxes are for creating BiNormal lines and/or Normal lines. Bothsides uses the line factory to extend the lines to the other side of the 3D curve. User Loft of the lines creates a Ribbon effect. 5. Press the Update pushbutton. It is from the Pipe2 command. 6. Depending upon the Style setup, if there are Normal lines, they will change color a couple of seconds after completion, to the next color. The Moebius papers talk of using an "anti-Frenet" frame where Kappa is zero. This term does not appear in google searches. I think that this is an "isolated inflection point." Maybe B and N can be negated there? http://arxiv.org/abs/1302.3175 So there is a lot of room for improvement. Using a formula for Kappa and Tau would be faster, but I do not have a formula for the Moebius strip centerline. - Brian EDITED: 17 Aug 2014 by BEMFARMER