MoI discussion forum
MoI discussion forum

Full Version: Elastica script

Show messages:  1-17  18-26

From: bemfarmer
27 Jul 2022   [#18] In reply to [#17]
This has been partly mentioned above.

Let "a" be a number representing a coordinate.

The _Elastica2 script displays an error message, in all 4 views, for a center point with ( x, y, z ) coordinates ( a, -a, 0 ) or ( -a, a, 0 ).

The error message in MoI3 shows a line in the Script section of the _Elastica2.htm file:
code:
var Frame = moi.vectorMath.createFrame( FrameOrigin, FrameXAxis, FrameYAxis );


The error message in MoI4, or MoI5beta, is the previously posted:
Script error
Invalid function argument
line 0
OK button.

- Brian
For nonzero z, coordinates ( a, -a, z ) or ( -a, a, z ) creates a curve, but with the strange angle mirror2 bug.

Will try some different code tonight or tomorrow, with better understanding of cplanes and Frames.
From: Michael Gibson
27 Jul 2022   [#19] In reply to [#18]
Hi Brian,

re exception here:
code:
var Frame = moi.vectorMath.createFrame( FrameOrigin, FrameXAxis, FrameYAxis );

In order to form a coordinate system the given xaxis and yaxis can't be parallel to one another.

Ideally they should be at a 90 degree angle to each other so they directly form an orthonormal frame. But it will tolerate if they are not 90 degrees to each other but they can't be parallel because they need to have a z axis direction formed by the cross product between them.

So if the angle between them is less than 2 degrees it will throw an "Invalid argument" exception.

- Michael
From: bemfarmer
27 Jul 2022   [#20] In reply to [#19]
Thank you Michael.

Your help, and Cross product information makes sense.

I'll be doing some corrections to the elastica2 script over the next few days, as work and energy level allows :-)

- Brian
From: bemfarmer
27 Jul 2022   [#21]
The string name of the current Viewport, in which a point was just picked.
Result is one of ( 3D, Top, Bottom, Front, Back, Right, Left )

code fragment in _Elastica2Test script.

code:
	var pointpicker = moi.ui.createPointPicker();
	if ( !GetPoint( pointpicker ) ) return;
	moi.ui.commandUI.cplane = pointpicker.ptframe;
	moi.ui.commandUI.referencePt = pointpicker.pt;

	var vpName = moi.ui.getActiveViewport().name;

	moi.ui.alert( 'viewportName = ' + vpName ); 


- Brian
From: bemfarmer
4 Aug 2022   [#22]
_Elastica3Aug5_OK_Draft is a pretty good version of _Elastica3 script.
It is not finished.
Should add rudimentary extrude (?), using Max S techniques, if this is possible.
Should add Help File, or else Help PDF.

Crucial help from Michael enabled the creation of the cPlane2 frame, for rotation and mirror2.
The user selects a reference point in one of the 7 MoI viewport Views, and the resulting 2D Elastica curve appears.
Looking at this curve in another View looks as expected, a Top or Front, or Right appearance, etc.

Running the script again, and selecting another point in any other of the 7 Views, with the same shape parameter,
produces an Elastica curve with the same appearance as the first selection in the other view.
This is due to using cPlane1 frame from pointpicker.

The Script has nearly all of the code in the .js file, not in .htm file.

Said goodbye to DarkGoldenRod color, for the pushButtons.
The DarkGoldenRod color for pushButton text was Okay, but the look of the theme text color for Default and Dark Themes is a bit better.
The pushButtons show elastica curve for 7 values of shape parameter.
The shape slider produces a near continuous progression of shapes.

The script works in MoI3 (slight delay), and also in MoI4, and MoI5beta.

I believe that the bugs of _Elastica2 are gone.

Number of points should be relatively high.
A trial of a Control point curve had a poor look between the two joined halves, so InterpCurve was used instead.

One curiosity is that the intersection of the "figure 8" elastica, when zoomed way way in, appears offset from the reference picked point.
But the distance of the offset from the reference point shows up as 000000.
Earlier trials had the join(s) eliminating the visual offset, but that is no longer happening, with the current join order.
The value of shape = 0.65223 was calculated in the source paper, and is not exact.

- Brian

Attachments:
Elastica3Aug5_OK_Draft.zip


From: bemfarmer
6 Aug 2022   [#23] In reply to [#22]
After doing some testing, I have come to the conclusion that the MoI Rebuild command (refit mode) does not work for the figure 8 elastica, a closed curve.
(Tested in MoI4, and MoI5beta.)
The Rebuild, # Points option worked.
Rebuild works for an open, almost figure 8 curve.
Is this a "bug" in Rebuild, or a result of the closed geometry of the figure 8? Tolerance calculation?


In other discoveries, a point count of 2 tends to make a zig zag curve.
A point count of 3 makes some different curves.
A point count of only 10 makes some fairly decent curves.

Added a help window, and cleaned up the .htm file a bit. (q.v.)

Now to tackle the rudimentary extrusion...

Name: ...Aug6Draft
- Brian

Attachments:
Elastica3Aug6Draft.zip


From: Frenchy Pilou (PILOU)
14 Oct   [#24]
French Version! :)
https://moiscript.weebly.com/bemfarmer-2.html




From: Michael Gibson
15 Oct   [#25] In reply to [#23]
Hi Brian,

re:
> Is this a "bug" in Rebuild, or a result of the closed geometry of the figure 8? Tolerance calculation?

Looks like a bug, I will investigate.

Thanks, - Michael
From: Michael Gibson
15 Oct   [#26] In reply to [#23]
Hi Brian, I think the refit bug is from the particular shape. It happens to have the start point, mid point, and end point all on the same location.

This then messes one of the refit steps since trying to interpolate a curve through 3 coincident points will fail.

I'll see if I can get it to pass through that stage.

- Michael

Show messages:  1-17  18-26