EggHalf Parametric Script

Next
 From:  bemfarmer
4489.1 
Attached please find Script to create Egg Shape, using equations of Tadao Itou, whom can be googled.
(There is an egg thread over on Alibre Forum.)
Only half an egg is needed due to MoI's abilities.

There are an infinite number of parametric scripts possible.
Some parametric scripts create curves which MoI users may benefit from.

I was wondering if such curves become Nurbs curves, and also their level of accuracy?

Once again, the ToroidalHelix script was used as the model. It is almost a blueprint for parametric equations. :)


EDITED: 19 Feb 2014 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:  Michael Gibson
4489.2 In reply to 4489.1 
Hi Brian,

> I was wondering if such curves become Nurbs curves, and
> also their level of accuracy?

Yes, all curves that you see in MoI are NURBS curves. NURBS curves can represent some kinds of curve shapes exactly, like arcs, or parabolas. Some other kinds of curves can't be formed exactly by a NURBS curve though and in that case the analytic curve that you are trying to create has to be approximated by making a flexible NURBS curve with a bunch of points in it that follows the same shape of the desired precise curve. That's generally called a curve fitting process.

The ToroidalHelix script method places the control point hull of the NURBS curve right at the exact location of the curve function. The actual curve geometry itself does not pass directly through the control point hull (except at the first and last point) but will approach it very closely if you use plenty of points.

It could be possible to use a different method for creating the curve which would be to interpolate the points - that would be using the "InterpCurve" command (Draw curve > Freeform > Through points) rather than the control point curve command for the actual curve construction. It's easy to try that in the script - in the spot of the script where it calls moi.command.createFactory( 'curve' ); instead have it call moi.command.createFactory( 'interpcurve' ); - they should both take the same kind of inputs so I think all the rest of the script should still work the same.

An interpolated curve is made to pass directly through the given points - so that helps some with increased accuracy since there are then many points where the curve is exactly on the true function's point instead of only just approaching it everywhere.

However, interpolation can kind of overly constrain a curve and has a tendency to introduce wiggles, so it's not necessarily a slam dunk that it's always better. But if you are matching to a nice smooth function and use plenty of points interpolation should work well and would probably give you more positional accuracy but probably with a trace amount of tangent wobble as the tradeoff.

But it should be easy to just try swapping in 'interpcurve' in the createFactory() call to give it a try...

- 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
4489.3 In reply to 4489.2 
Thank you.
  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:  YHWH_777
4489.4 In reply to 4489.3 
I tried to run the script (EggHalf.js), by starting up MoI with the script as a parameter, but I get a Script error which states "Line 30 Column 1:".

I have never executed a script from MoI before, so I am not positive that I am doing it correctly. Can someone lend a helping hand?
  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
4489.5 In reply to 4489.4 
Hi YHWH_777 - these scripts are meant to be as a command - when you give a .js as a command line parameter that's trying to execute the script on program startup which is a bit different kind of thing.

For this one, copy the 2 files EggHalf.htm and EggHalf.js to the \commands sub-folder underneath MoI's main installation folder.

That will then make a new command named EggHalf available for MoI to run - to launch it either type Tab and type the command name and push enter, or set up a shortcut key with that name in the command column for the shortcut.

- 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
 From:  YHWH_777
4489.6 In reply to 4489.5 
Thanks for the explanation. It works fine now.
  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