Browse Search Popular Register Upload Rules User list Login:
Search:
Triangle Spawner

Image:
screenshot of the scene

Author: Xray

Group: Default

Filesize: 85.61 kB

Date added: 2014-04-10

Rating: 5

Downloads: 562

Views: 207

Comments: 14

Ratings: 1

Times favored: 0

Made with: Algodoo v2.1.0

Tags:

Scene tag

This will spawn triangles of your desired size and color. Instructions are in the scene.

UPDATE: I improved the scene by spawning a triangle each time any of the clickable values or color boxes are clicked. This way, you can watch the shape and size of the spawned triangle change before your eyes with each click. Rather than a bunch of new triangles getting spawned (as was the case for the previous version) only ONE triangle gets spawned, and the previous spawned triangle gets killed (deleted). When you are satisfied with how it looks, simply remove the triangle or copy it (Ctrl-C) and then paste it into your other scene.

UPDATE2: Fixed bug that prevented scene from working. (Thanks kilinich!)

I hope you like the new version better than the old version.
Last edited at 2014/04/11 01:41:12 by Xray
Please log in to rate this scene
edit
Similar scenes
Title: Geometric problem
Rating: 5
Filesize: 24.13 kB
Downloads: 223
Comments: 0
Ratings: 1
Date added: 2020/02/27 01:38:31
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Decorative Spinning Triangle
Rating: 5
Filesize: 6.7 kB
Downloads: 123
Comments: 0
Ratings: 1
Date added: 2012/11/23 02:06:07
Made with: Algodoo v2.0.1 Edu
Rating: rated 5
download
Title: Best Spawner Car I Ever Made!! Read Desc
Rating: 5
Filesize: 52.07 kB
Downloads: 314
Comments: 3
Ratings: 1
Date added: 2010/09/12 00:24:22
Made with: Algodoo before v1.8.5
Rating: rated 5
download
Title: Planck Length Triangle Circle Geometry.
Rating: 5
Filesize: 15.23 kB
Downloads: 257
Comments: 0
Ratings: 1
Date added: 2011/08/15 20:49:34
Made with: Phun
Rating: rated 5
download
Title: Treaded Triangle vs Simple Car
Rating: 5.5
Filesize: 62.21 kB
Downloads: 217
Comments: 0
Ratings: 2
Date added: 2008/12/26 14:48:19
Made with: Phun
Title: TRIANGLE CUTTER
Rating: 5.4444
Filesize: 14.24 kB
Downloads: 518
Comments: 1
Ratings: 3
Date added: 2009/09/08 00:43:09
Made with: Algodoo demo
Rating: rated 5.4
download
It's not working for me. I reset Algodoo and checked the code. I don't see any polygon spawning code.
I downloaded the scene again just to make sure that it still works, and it does. I also entered into the console "drawtriangle" (without the quotes) and it printed the function.

I don't see complaints from anyone else, and so I wonder what's going on here.
drawtriangle declared in root container, not in scene.my
that's why it's not saved with scene
Yours Is way better. Yours is exactly what I was trying to make.
I should know better than to declare a function only in the root scope and not declare it as scene.my (searialized), but that's what happened. The function "drawtriangle()" is now "scene.my.drawtriangle()". Thanks to kilinich for catching this! :tup:
Still not working. Opened .phz and scene.my.drawtriangle is called but not defined.
Try it now. I uploaded a new file. You should see scene.my.drawtriangle function in the console.
Last edited at 2014/04/11 00:11:46 by Xray
Nope, still not working. download 80869_Triangle_Spawner.phz and rename it to 80869_Triangle_Spawner.zip. Open the zip and then open scene.phn with Wordpad. Tell me if you see scene.my.drawtriangle defined in the code. I don't see it.
NO, I do not see the defined function! That is so weird because the scene works fine on my computer.

I defined the function in the console, and so it should work (but obviously it doesn't for everyone but me!). So, what the heck did I do wrong? :s

EDIT: Okay, I got it now! It just goes to show how picky Thyme is when defining functions. I originally defined scene.my.drawtriangle like this:

Scene.my.drawtriangle = (a, b, c, d)=>{
scene.my.error = false;
(a >= (b + c) || b >= (a + c) || c >= (a + b)) ? {
scene.my.error = true
} : {
x = {
((a + (c ^ 2 - b ^ 2) / a) / 2)
};
y = {
(c ^ 2 - x ^ 2) ^ (0.50000000)
};
Scene.addPolygon({
surfaces := [[[0, 0], [a, 0], [x, y]]];
color := d;
collideSet := 3;
body := 0
})
}
}

Obviously, that did not work. So I added the colon, and now it works:

Scene.my.drawtriangle := (a, b, c, d)........

OY!:bonk:
Last edited at 2014/04/11 01:47:40 by Xray
Yes. OK now.
Thanks for all your help, Steve! I appreciate it very much. :)
Now that you have the scene functioning, you need to work on accuracy. The displayed side size is sometimes off by ~0.1 because it's not rounded up. Also a 20.0 side is off by 0.00004.
Yes, I already knew that but my focus until now has been getting the scene working. In fact, there are some invalid values that will not produce a triangle (as expected), but the error trapping routine does not display an error message. I think that's part of the same issue as the accuracy issue.

Thanks again.

Edit: I'm not going to worry about the 20.0 side being off by 0.00004! :lol: If that's true (and not your joke), then it's due to Algodoo floating point precision error, which I can't do anything about anyways (except maybe truncate everything beyond 3 decimal digits).
Last edited at 2014/04/12 00:53:24 by Xray
Regarding "which I can't do anything about", you give up too easily. I will give you a hint: In Algodoo 200*0.1 = 20.
Last edited at 2014/04/12 11:23:24 by s_noonan