Catenary Script

Next
 From:  bemfarmer
4454.1 
Attached is a simple Catenary Script. It makes a nice revolve.

Catenary or Arch script for MoI
August 26, 2011
By Brian McMillin
The procedure for creating a Catenary or Arch script for MoI began to become clear after a lot of google searches. A Catenary curve is the shape produced by a wire or chain or rope, or other material, which is inelastic and flexible, and is suspended from two supports. It resembles a parabola, but is a different curve. In an X,Y coordinate system, when the catenary is oriented symmetrically about the Y axis, vertex intersecting the Y axis, with gravity in the negative Y direction, the equations for the catenary are as follows:
Y = a*cosh(x/a) = ( a/2)* ( e^(x/a) + e^(-x/a) )
Where the a parameter is the minimum Y value, at the intersection of the Y axis.
(See Wikipedia for graphs, mathematics, and further information.)
The parametric equivalent equation for the catenary, where t = 0 at Y axis vertex, is:
x(t) = t
Y(t) = a*cosh(t/a) = ( a/2)* ( e^(t/a) + e^(-t/a) )
Here is my first rudimentary effort to create a script for half of a catenary, “CatenaryHalfDraft”
It is based upon modifying the existing “ToroidHelix” script.
Enter a maximum value for X. (positive)
Enter a value for a. (positive Y vertex)
Enter a value for Points per X unit.
Checkbox for Arch. (Haven’t figured out check boxes yet. Not really needed.
CatenaryHalf is a rudimentary script for MoI, which creates half of a catenary. Mirror other half of catenary. Rotate and move for an Arch.
A more professional script would interactively hang a catenary by selecting two points of different heights, given either a Length of catenary arc, or a third point on the catenary, and perhaps behave similarly to the Conic command.
Internet search revealed non-copyrighted posts by elbarto and opalg (mathematics), as well as Grasshopper script posts by Giulio Picentino, and Daniel Davis. A MoI script should be possible, without copying any of the scripts, by using mathematics described by opalg and others. As the equations are not analytically solvable, this requires numerical methods, such as Newton-Raphson, and “hill climbing.”



EDITED: 27 Mar 2012 by BEMFARMER

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
4454.2 
Cool try of coding!

Seems perfect for bullets, warhead or suppository :)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
4454.3 In reply to 4454.2 
:D
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
4454.4 In reply to 4454.1 
Hi Brian, that's great that you've been able to get it all working!

The way that you would do a checkbox is to add a <moi:CheckButton> element to the .htm file that contains the UI for the command.

You need to give it an id="" attribute and fill in the inside of the tag with the text that will go in the button, so it will look something like this:

code:
<moi:CheckButton id="someid">Text label goes in here</moi:CheckButton>



Basically when you have a control (any kind of button or input control) in the UI that has an id assigned to it, when that control gets activated it will trigger a UI event that your .js file can then respond to.

The event will have the name of the id="" attribute of that control and you can retrieve the current true/false property for whether it is checked or not by using the .value property of the control - that works similar to how the script is currently retrieving the .numericValue property from the edit fields. And actually in MoI v3 you can use just plain .value for those numeric fields as well.

Let me know if you are still stuck trying to use a check box and I can help you get it set up.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
4454.5 In reply to 4454.4 
Thankyou Michael.
More to come, later after work...
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
4454.6 
Attached is an unofficial Catenary curve creation script.

It works well in the TOP view.
Catenary2PtXY is a script which produces a catenary in the xy plane, from two points picked by the user.
Gravity is in the negative y direction.
In the event that the z coordinates of the two points are not equal, an alert requiring equal z coordinates is given.

This script uses the Opalg math, and most of the elbarto code.

Nearly all of the MoI Distance script is used to select the two points, and measure the distance between the two points.
The user inputs the chain length, which must be greater than the distance between the two points, or a catenary will not form.
In the event that a catenary does not form, even though the chain length is greater than the distance between the two points,
OR if the catenary is upside down, the Newton-Raphson method has failed, and the user can adjust the GuessRadius parameter,
to be smaller or greater than 1.0.

For a chain length that is long in relation to the x-axis distance between, try a fractional GuessRadius.
For a chain length that is slightly longer than the x-axis distance, try a GuessRadius greater than 1.

An ARCH seems to be formed if a negative GuessRadius is used.

An explanatory PDF titled "Catenary Suspension from Two Points" is being edited, and may be posted later, if anyone is
interested.

Edit: 3/23/2012 Replaced Catenary2PtXY with slightly modified htm. Now works with MoIversion 2 (Windows)
Do not have a Mac...

Still working on a version which will also accept different z coordinate values, by using a coordinate frame...

EDITED: 23 Mar 2012 by BEMFARMER

Attachments:

Image Attachments:
Size: 98.9 KB, Downloaded: 89 times, Dimensions: 580x333px
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael T. (MICTU_UTCIM)
4454.7 In reply to 4454.6 
Very cool. Thanks for the great script bemfarmer.

Just to clarify, this only works with the Beta V3 version, correct? I tried it with V2 and I get a script error.

Michael T.
Michael Tuttle a.k.a. mictu http://www.coroflot.com/DesignsByTuttle
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
4454.8 In reply to 4454.7 
I never tried version 2......should have...
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
4454.9 
Edit: 3/23/2012 Replaced Catenary2PtXY with slightly modified htm. Now works with MoI version 2 (Windows)
(Had an extraneous line of code in the htm.)

Do not have a Macintosh. Perhaps someone will try it out there?
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael T. (MICTU_UTCIM)
4454.10 In reply to 4454.9 
Just downloaded it bemfarmer, I'll give it a spin.

Thanks,

Michael T.
Michael Tuttle a.k.a. mictu http://www.coroflot.com/DesignsByTuttle
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael T. (MICTU_UTCIM)
4454.11 In reply to 4454.9 
That did the trick bemfarmer. Works great in v2 now!

Michael T.
Michael Tuttle a.k.a. mictu http://www.coroflot.com/DesignsByTuttle
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  bemfarmer
4454.12 
Note: this is an Unofficial script, by an amateur programmer...
The script works pretty good. It needs an adjustment to "aGuess" if the two points are close together, "relative" to the arclength S.
Values of .1 to .5 seem good in that situation. Some additional code to assist NewtonRaphson may be in order.

Here is an updated script which will Also accept points with different z values.
Gravity is still in the -y direction. The two points cannot be vertically one above the other.

Also attached the rambling PDF about catenaries, which has been edited numerous times, but may still have errors...

Just added in a coordinate frame, using previous explainations of Michael, to temporarily rotate the x-axis about the new parallel y-axis, which effectively converts
the z coordinates to zero, so that the prior Catenary2PtXY code is re-used.

Changing the direction of gravity, or finding S given "a," have not been done.

EDITED: 8 Nov 2012 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All