Shared Functions()

Discussions and file drops for Auggie
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4591
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Shared Functions()

Post by ArtF »

Glenn:

    A video is just uploading on general screen design, though it sounds like your beyond it anyway...
Ill include the Monkey Docs in next release as well, though I'm sure you've found them by now
online. 


Art
GlennD
Old Timer
Posts: 80
Joined: Tue Oct 18, 2011 4:19 pm

Re: Shared Functions()

Post by GlennD »

Art
Fleshed out some thing on buttons and what not that I was unsure of so very helpful.

Thanks
Merry Christmas.
Ya-Nvr-No
Old Timer
Posts: 188
Joined: Wed Sep 08, 2010 11:15 am

Re: Shared Functions()

Post by Ya-Nvr-No »

I read some concerns about scripting and motion directly from scripting.

Well why not open a file in the function and write to the file as formatted gcode?

after all its just math and numbers all doing the same thing.

What do you think a Post Processors does ???

So there is no reason not to create functions that can give us unique shapes and post the data out to your gcode read only controller.

Embrace scripting as a new vehicle to give you a new creative tool.

PS: This was my crude way to do it but it shows that its an easy process.

I'd like to see a function created, we just pass the positional data too and it writes the Gcode.
that way ever function can use the same GCodeOut() function

Code: Select all

g0 z1
g0 x0 y0
g1 z-.1
x0.100 y0.010
x0.196 y0.040
x0.287 y0.089
x0.368 y0.156
x0.439 y0.240
x0.495 y0.339
x0.535 y0.451
x0.557 y0.574
x0.559 y0.705
x0.540 y0.841
x0.499 y0.980
x0.435 y1.118
x0.348 y1.253
x0.238 y1.380
x0.106 y1.496
x-0.047 y1.599
x-0.219 y1.686
x-0.409 y1.753
x-0.614 y1.798
x-0.832 y1.819
x-1.060 y1.813
x-1.295 y1.779
x-1.532 y1.715
x-1.770 y1.621
x-2.003 y1.496
x-2.228 y1.340
x-2.441 y1.154
x-2.638 y0.938
x-2.816 y0.694
x-2.970 y0.423
x-3.097 y0.129
x-3.195 y-0.187
x-3.259 y-0.521
x-3.287 y-0.869
x-3.278 y-1.228
x-3.228 y-1.593
x-3.138 y-1.960
x-3.006 y-2.325
x-2.831 y-2.682
x-2.615 y-3.027
x-2.357 y-3.355
x-2.059 y-3.661
x-1.723 y-3.940
x-1.352 y-4.187
x-0.949 y-4.399
x-0.516 y-4.571
x-0.058 y-4.700
x0.420 y-4.782
x0.914 y-4.814
x1.418 y-4.795
x1.928 y-4.722
x2.436 y-4.594
x2.938 y-4.411
x3.427 y-4.173
x3.898 y-3.880
x4.343 y-3.535
x4.758 y-3.139
x5.136 y-2.695
x5.472 y-2.206
x5.761 y-1.677
x5.998 y-1.111
x6.179 y-0.515
x6.299 y0.106
x6.356 y0.746
x6.348 y1.398
x6.272 y2.056
x6.126 y2.712
x5.912 y3.360
x5.629 y3.991
x5.277 y4.599
x4.860 y5.176
x4.380 y5.714
x3.840 y6.208
x3.245 y6.650
x2.600 y7.035
x1.910 y7.356
x1.181 y7.609
x0.421 y7.789
g0 z1
Attachments
createGcode.JPG
Last edited by Ya-Nvr-No on Fri Dec 25, 2015 1:15 am, edited 1 time in total.
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: Shared Functions()

Post by DanL »

A function that would take info out of a .csv would be good, then you could do a spreadsheet and use voronoi math to do spirals. I have info on how to do this in another computer language.

I might see if I can find it and have a play.
Ya-Nvr-No
Old Timer
Posts: 188
Joined: Wed Sep 08, 2010 11:15 am

Re: Shared Functions()

Post by Ya-Nvr-No »

playing around, made a couple alterations.

global Phi=Const.Gold; //Fibonacci Golden Ratio, a special number approximately equal to 1.6180339887498948482
global phi=Const.Gold-1;

x = (t * math.cos(t))*Phi;
y = x*((t * math.sin(t))*phi);

tweak the sign can give you some big changes and can create some interesting patterns.
learn what tables and arrays can be used for and how you can take spreadsheet data and paste it into one or more tables. Then use the tables as a source of data points.

Investigate web sites that teaches or inspire you to use math again, like:   http://mathforum.org/dr.math/faq/
find some old source code that does something cool or you can relate to.
maybe something you would like to see plotted or someday cut out for a conversational drink holder or welcome mat.
teach your kids how math is something they can have real fun with and produce their results with your machine.

Auggie can be an inspirational & educational tool that produces CNC movement for the creative and/or inquisitive mind.  8)
Attachments
bug2.JPG
spider.JPG
bug.JPG
Ya-Nvr-No
Old Timer
Posts: 188
Joined: Wed Sep 08, 2010 11:15 am

Re: Shared Functions()

Post by Ya-Nvr-No »

GlennD wrote: P.S. Did look up the Game Monkey and it does mention that no switch is available so blocks of if statements it is.  :D
I found this example and it worked for me.

Code: Select all

name = "pear";
switch (name)
{
  case "apple": { print("hurrah "); print("for apples"); } // braces are required
  case "banana":                                       // Fall through multiple cases
  case "pear":
  case "cherry": { print("fell to fruit", name); } 
  case favoriteFruit: { print("my favorite fruit"); }     // allow variable cases!
  default: { print("no fruit for you"); }                 // Default not required
}

 fell to fruit pear  
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: Shared Functions()

Post by DanL »

Ya-Nvr-No
Old Timer
Posts: 188
Joined: Wed Sep 08, 2010 11:15 am

Re: Shared Functions()

Post by Ya-Nvr-No »

How about a simple sorting routine?

Code: Select all

global  BubbleSort = function(iarray,num)  
{	
d={""};
   print("Unsorted Data:");
&nbsp;  for (k = 0; k < num; k=k+1) 
&nbsp;  {
&nbsp; &nbsp; &nbsp; print(iarray[k]);
&nbsp;  }
&nbsp;  for (i = 1; i < num; i=i+1) 
&nbsp;  {
&nbsp; &nbsp; &nbsp; for (j = 0; j < num - 1; j=j+1) 
&nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;  if (iarray[j] > iarray[j + 1]) 
&nbsp; &nbsp; &nbsp; &nbsp;  {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = iarray[j];
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iarray[j] = iarray[j + 1];
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iarray[j + 1] = temp;
&nbsp; &nbsp; &nbsp; &nbsp;  }
&nbsp; &nbsp; &nbsp; }
&nbsp;  }
&nbsp;  print("Sorted & After pass: " + k);
&nbsp;  for (k = 0; k < num; k=k+1) 
&nbsp;  {
&nbsp; &nbsp;  print(iarray[k]);
&nbsp; &nbsp;  d[k] = iarray[k]; 
&nbsp;  }
return;
};
a={33,6,11,3,"k","e","y"}; // the data array
b=tableCount(a); // number of items in the array
BubbleSort(a,b);


Unsorted Data:&nbsp; 
 33&nbsp; 
 6&nbsp; 
 11&nbsp; 
 3&nbsp; 
 k&nbsp; 
 e&nbsp; 
 y&nbsp; 
 Sorted & After pass: 7&nbsp; 
 3&nbsp; 
 6&nbsp; 
 11&nbsp; 
 33&nbsp; 
 e&nbsp; 
 k&nbsp; 
 y&nbsp; 


Ya-Nvr-No
Old Timer
Posts: 188
Joined: Wed Sep 08, 2010 11:15 am

Re: Shared Functions()

Post by Ya-Nvr-No »

Converting a Hex to a number
HexString is a Hex number represented as a string
Hex letters can be Upper or Lower case

Code: Select all

global&nbsp; HexStringToNum = function(HexString) 
{ 
&nbsp; &nbsp; HexString = ToString(HexString);
&nbsp; &nbsp; local char = "";
&nbsp; &nbsp; local rHexString = "";
&nbsp; &nbsp; local Val = 0;
&nbsp; &nbsp; local indx = 0;
&nbsp; &nbsp; local StringAsNum = 0;
&nbsp; &nbsp; local ZeroForNilChar = 0;
&nbsp; &nbsp; local StringLength = HexString.Length(HexString);&nbsp; &nbsp; 
&nbsp; &nbsp; rHexString = HexString.Reverse(HexString);&nbsp; &nbsp; 
//debug();
&nbsp; for (x = 0; x < StringLength; x=x+1)
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; indx = x + 1;&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; char = rHexString.Mid(indx-1,1);
&nbsp; &nbsp; &nbsp; &nbsp; if (char == null)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char = "0"; Val = 0;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }
&nbsp; &nbsp; &nbsp; &nbsp; if (char == "A" or char == "a")
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Val = (10 * math.power(16, indx-1));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; else if (char == "B" or char == "b")
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Val = (11 * math.power(16, indx-1));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; else if (char == "C" or char == "c" )
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Val = (12 * math.power(16, indx-1));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; else if (char == "D" or char == "d")
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Val = (13 * math.power(16, indx-1));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; else if (char == "E" or char == "e")
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Val = (14 * math.power(16, indx-1));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; else if (char == "F" or char == "f")
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Val = (15 * math.power(16, indx-1));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; else //&nbsp; if (char.String != "string")
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Valt = ToInt(char);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (Valt == null) 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ZeroForNilChar = 0;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Val = 0;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vals = ToInt(char);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Val = (Vals * math.power(16, indx-1));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }&nbsp; &nbsp; &nbsp; &nbsp;  
&nbsp; &nbsp; &nbsp; &nbsp; StringAsNum = StringAsNum + Val; 
&nbsp; &nbsp; &nbsp; &nbsp; local dummy = 0;
&nbsp; &nbsp; &nbsp; &nbsp; } 
&nbsp; &nbsp; local dummyvar = StringAsNum;
&nbsp; &nbsp; return StringAsNum;
};
stringasnum = HexStringToNum("22AF2DE");
print(stringasnum);

36369118

Ya-Nvr-No
Old Timer
Posts: 188
Joined: Wed Sep 08, 2010 11:15 am

Re: Shared Functions()

Post by Ya-Nvr-No »

temperature conversions

Code: Select all

global&nbsp; Temp_F_to_C = function(F) 
{
&nbsp; F=ToFloat(F);
&nbsp; celsius=(5.0/9.0)*(F -32.0);
&nbsp; return celsius;
};
global&nbsp; Temp_C_to_F = function(C) 
{
&nbsp; C=ToFloat(C);
&nbsp; Fehr=((9.0/5.0)*C) +32.0;
&nbsp; return Fehr;
};
User avatar
Mooselake
Old Timer
Posts: 522
Joined: Sun Dec 26, 2010 12:21 pm
Location: Mooselake Manor

Re: Shared Functions()

Post by Mooselake »

The linked GM (have to wonder if GameMonkey was an obvious choice for Gearotic Motion :) ) script reference only mentions switch() in an example, although they say it uses flex as a parser. &nbsp;Too many family things going on today to dig deeper today (like how much of flex gets carried along, does based on mean incorporating?). &nbsp;The Lua reference doesn't mention switch either. &nbsp;Something strange is going on here... &nbsp;I'll mention I'm not very enthused about the "read the source code and figure it out" style of documentation, but maybe that's necessary to see just what's included in the language.

Wonder if you could use array constructors to do pre-sorted tables? &nbsp;From the quick doc scan that's kinda ambiguous, too.

Kirk


User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4591
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Shared Functions()

Post by ArtF »

Kirk:

&nbsp; Its a fantastic scripter, but there are tons of ambiguities.. :)

Art
User avatar
Mooselake
Old Timer
Posts: 522
Joined: Sun Dec 26, 2010 12:21 pm
Location: Mooselake Manor

Re: Shared Functions()

Post by Mooselake »

ArtF wrote:Its a fantastic scripter, but there are tons of ambiguities.. :)
That's what makes it so much fun :)

I found a lengthy discussion of Tempest on the Mach3 forum that's taking a big chunk of that elusive spare time, plus the head scratching is risking the few remaining follicles.&nbsp; I didn't realize that you'd discovered 3rd order S curve motion long before the tinyg guys, but I'm not surprised.

Kirk
Last edited by Mooselake on Fri Dec 25, 2015 9:53 am, edited 1 time in total.
GlennD
Old Timer
Posts: 80
Joined: Tue Oct 18, 2011 4:19 pm

Re: Shared Functions()

Post by GlennD »

Group, sorry about the switch thing, I thought I had tried the braces in the case portion guess not.
I had tried several variants before I went looking at the Game Monkey stuff.

Hope everyone is having a wonderful Christmas.

Glenn

Edit:
Even funnier is when you look further down on the page as linked above and where I found that it said didn't use switch. you see switch used in the Constructor with Parameters example. &nbsp;The example isn't using the braces.

Attachments
GM Switch.PNG
Last edited by Anonymous on Fri Dec 25, 2015 3:30 pm, edited 1 time in total.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4591
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Shared Functions()

Post by ArtF »

Glenn:

:), yes, your seeing my only issue with Game Monkey script, its a bit hard to figure the rules, and Ive modified it
quite a bit as well, the scripts are preemptive now in some cases for example, necessary for Auggie because someone,
somewhere at some time will do a

while(1) { };

and lock up a system with a thread that never ends. The system tries to detect that and will put to sleep
a thread that takes more than 50ms or so. If, ( and it can happen) this fails to happen and a system appears locked
from a thread you wrote, Auggie has a "Three-Finger Salute" that kills all running threads. Ctrl-Shift-Alt. This kills
any threads running.

&nbsp; Monkey Script is a very easy and fun language, unlike VB in Mach3, where I dreaded even thinking of writing a
routine, Im finding I actually like scripting in Monkey for the most part. Ive modified it here and there to suit
Auggies needs, the Docs will need work as I release data for you guys to see how things interact, but as a
script engine decision, Im pretty happy with GM script.

(It does sound as if it were made for Gearotic Motion doesnt it?)

&nbsp;Im glad youve enjoyed playing in it, between you and YNN its firming up how I will go forward
with the next scripting system dedicated to the GCode callable scripts. Its a challenge to make that easy,
not too complex and powerfull enough to make a differerence.
&nbsp; &nbsp; &nbsp;I've decided I'll be doing it to a similar fashion as World of Warcraft Plugins actually, so the
worlds gaming systems are definitely having a major impact on Auggies development, and before
anyone thinks thats a disparaging thing to say, consider for a moment that just Game Monkey Script alone probably
has more development investment in it than Mach3 did after 4 years of development.
World of Warcraft has had hundreds of millions of dollars spent in their development over 10
years, and I follow such things as proof of direction for evolving software when I write things.

&nbsp; Now Im not as good as they are, so you guys need to keep commenting on what you
find easy, and what you find nasty, where I can adapt I will. &nbsp;

Thx
Happy New Year
Art


Last edited by ArtF on Sat Dec 26, 2015 3:10 am, edited 1 time in total.
Post Reply

Who is online

Users browsing this forum: No registered users and 60 guests