Clothoid 2 point curve script
 1-17  18-35

Previous
Next
 From:  Michael Gibson
5878.18 In reply to 5878.17 
Hi Brian, *.htm files for commands in MoI are the same as HTML files that are displayed in web browsers, the upper-right area of MoI's main window basically has an embedded web browser there that loads the HTML content. You can also have script in that HTML content same as you can in HTML files that are displayed in a regular web browser. There are a few different ways that scripts can be declared on a web page, it's possible to have an event handler declared in something like an onclick="" attribute on a button but if you have some pretty big functions it's more typical to have those functions declared in a <script> block that you put in the <head> portion of the HTML page.

The command script (the .js file part of a command) can call script functions that are in the HTML page, the root object of the HTML page is available under moi.ui.commandUI , and any script functions declared on that page end up as global variables there, so if you have a function in HTML called blah() like this:

code:
    <html>
        <head>
              <script>
                  function blah()
                  {
                      .....
                  }
               </script>
        </head>
     
      .......



That function defined in the HTML file can be called from the .js file by: moi.ui.commandUI.blah();


I've attached an example where I've edited your Clothoid2ptDraft2b command to move a bunch of the script construction logic over into the HTML file which is then called in this manner from the .js file.


The script code that is declared inside of the HTML file will have fairly different performance characteristics than the code that's run in the .js file - that's because the HTML page runs directly inside of the main MoI.exe process, while a regular command's script file runs in a separate process: moi_commandprocessor.exe and it talks to MoI.exe whenever you make calls into any MoI object. The main reason for this inter-process communication is to make it harder for scripts to be able to crash or lock up MoI, with the script being in a different process it's a lot easier for MoI to forcibly terminate that script at any time without anything happening to the main moi.exe process.

Script code that you run directly inside of the main MoI process will have less overhead to each MoI object call that's done in it, but it will also be easier for the script to lock things up if it goes into a tight loop or things like that as well.


In the future I'd like to make a type of "script factory" mechanism that would make it possible to write some script that would run in a separate worker process but have in-process calls for geometry access and vector math type functions so that the script would not have as much overhead.

The way regular MoI commands are set up though the scripts are mostly used for control flow logic and not for doing heavy duty calculations directly in a script - heavy calculations happen in the geometry factories that are currently written in C++ and they have that kind of direct geometry access even though they run in a separate worker because any geometry that's being used by the factory is sent over to the worker process so that it can then access it locally as it does calculations on it.


So anyway basically right now things are not really optimized for the case of doing heavy calculations directly in script, but you may get some lower overhead for scripts that are contained inside of the HTML part of the command which is normally where the UI controls go. You can have script code in there as well though if you want by using <script> tags. Hope this explains a bit more of how things are currently set up to work.


- 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
5878.19 In reply to 5878.18 
Michael, thank you very much for these details.
I'll study them after work...(I've been to busy to do much lately.)

There is a new paper called "Super Space Clothoids," which are 3D, but the math is very difficult.
http://hal.inria.fr/docs/00/84/03/35/PDF/eulerspiral.pdf

-Brian

EDITED: 9 Jul 2013 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

Previous
Next
 From:  Frenchy Pilou (PILOU)
5878.20 In reply to 5878.19 
Made in France! :)
---
Pilou
Is beautiful that please without concept!
My Gallery
  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:  Mauro (M-DYNAMICS)
5878.21 In reply to 5878.20 
..French Pride.. ;) :)
  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
5878.22 In reply to 5878.20 
Oui :-)
  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
5878.23 
After a long hiatus, spent a few hours adding two sliders for the start and end angles of the clothoid.
It only took a few minutes to add the sliders, but a lot longer to get everything working more or less properly,
due to limited programming skills and limited understanding.
Much of the code is in the htm file, as per Michaels post.

The MoI3 version of Blend command was used for the basic pattern, but had to modify it per Michaels help of many months ago, since
the sliders do not have a "clothoid factory" to work with. The sliders work "better" in Blend command, (in my opinion).

Is there some way to make the clothoid sliders update interactively, not just when the mouse button is released?

Angles can also be typed into the boxes.

The MoI3 version does not quite work in MoI2. MoI2 hangs up for awhile, but then permits exit from MoI2.
The MoI2 version of Blend appears to have a different line in the slider code.
Including this difference allowed a version that works in MoI2, and it also worked in MoI3.

Attached a MoI3 version, and also a MoI2 version, both with limited testing

Edit August 2, 2013...See August2 post for updated onmousemovevaluechange sliders for MoI3August1Beta.

EDITED: 3 Aug 2013 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

Previous
Next
 From:  Michael Gibson
5878.24 In reply to 5878.23 
Hi Brian,

> Is there some way to make the clothoid sliders update interactively, not just when the mouse button is released?

I'm sorry there's not any way to do that currently, at the moment the interactive slider stuff is only set to work through the property binding mechanism so it will only work for binding to a geometry factory input, not to trigger a script event for the interactive movement.

I'll see about putting in an option for the slider for generating continuous events for every mouse move.

- 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
5878.25 In reply to 5878.24 
Hi Michael,

Thank you.

- Brian
  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
5878.26 In reply to 5878.25 
Hi Brian, for the next v3 beta I've updated the slider control so it will fire an onmousemovevaluechange="...." script event for every mouse move, so you'll be able to put in a script handler for that event instead of just onvaluechange="" if you want to get more interactive events.

- 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
5878.27 In reply to 5878.26 
Thank you Michael.

I wonder if it will be useful for anything else...?

-Brian
  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
5878.28 In reply to 5878.26 
Attached improved onmousemove sliders for interactively adjusting clothoid start and end angles by slider, for MoI3BetaAugust1_2013.

Thanks to Michael for updating slider control.

-Brian

Edit: See next post for script files with big sliders

EDITED: 5 Aug 2013 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

Previous
Next
 From:  bemfarmer
5878.29 In reply to 5878.28 
Studied a bit of HTML code, and updated the htm file to display Big sliders.
Noticed a bit of brief shakiness of the curves.
-Brian
ps Discovered a re-write of the source paper at http://arxiv.org/pdf/1305.6644.pdf.
Have to study it to see if the Math is any more comprehensible.

EDITED: 5 Aug 2013 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

Previous
Next
 From:  Frenchy Pilou (PILOU)
5878.30 
here maybe for the yellow curve that is 30° & 90°
(a Clothoïd curve is slightly different than a Blend curve or Conic curve)

But does it possible to have directly the optimum result (yellow) without the sliders ?






Ps Have you a site where are all your Moi Scripts ?

EDITED: 14 Oct 2013 by PILOU

  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
5878.31 In reply to 5878.30 
Hi Pilou,

The problem is with getting and preserving the tangents at the beginning and end.
I am unable to extract the two tangents by clicking on the curve(s), using scripts.
(This is do-able using Nurbs equations, for an expert, for example the blend command.)
So instead, helper tangent lines are used.
A few months ago I did a script to utilize two helper line segments, at the beginning and end, which are
placed manually, as tangents. However, using the interpcurve or curve factories, to draw the clothoid, resulted
in a clothoid curve which were close to being tangent, but were not quite tangent, so the code was never polished up.
I may revisit it sometime. I do not want to post "sloppy" code, and try to polish it up, at least somewhat...

When I am tracing curve drawings using an image, Blend often works well. Sometimes a clothoid is very helpful, used to
help establish a curve, which blend can alter.

(Note that the factory curves are close approximations to such curves as clothoids, catenaries, sinewaves, etc.)

- Brian

Edit: I have not made a website yet :-)
  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)
5878.32 In reply to 5878.31 
thx for the infos!
---
Pilou
Is beautiful that please without concept!
My Gallery
  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)
5878.33 
...
  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
5878.34 
This is the current most recent version of Clothoid2pt script, with two sliders.
Got rid of negative point numbers.
Added Max Smirnov method of reducing slider flicker. (per ArchimedeanSpiral discussion)
Added Max Smirnov method of clicking on slider label to reset slider to midpoint.

(Hopefully there is not some configuration which does not work.)
The script still has lots of comments, which could be removed to a text file...

- Brian

Maybe Moi version 4 could have a method to make available endpoint tangents of a curve?
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
 From:  Michael Gibson
5878.35 In reply to 5878.34 
Hi Brian,

> Maybe Moi version 4 could have a method to make available
> endpoint tangents of a curve?

Yes, I would like to add some curve evaluation mechanisms to be available to scripts in v4.

- 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
 

Reply to All Reply to All

 

 
 
Show messages:  1-17  18-35