Predefined Polygons

About advanced scenes, and the Thyme scripting language used in Algodoo.

Predefined Polygons

Postby Papriko » Sat Dec 19, 2009 1:01 am

Just a very little and quick question: I want to create Polygons via scene.addPolygon with predefined size and shape. How do I put them correct into the { } brackets?
I am currently only using Phun 5.28 and not Algodoo. I would annoy the people on the Phun Forum and not here, but the Forum refused new registrations when I looked the last time.
Papriko
 
Posts: 29
Joined: Tue Nov 17, 2009 8:43 pm

Re: Predefined Polygons

Postby standardtoaster » Sat Dec 19, 2009 1:51 am

Code: Select all
Scene.addPolygon({vecs := [[x, y], [x, y], ...]})

Each point on a polygon is a point on the Cartesian Coordinate graph.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Predefined Polygons

Postby gradyfitz » Sat Dec 19, 2009 6:53 am

standardtoaster wrote:
Code: Select all
Scene.addPolygon({vecs := [[x, y], [x, y], ...]})

Each point on a polygon is a point on the Cartesian Coordinate graph.

Not quite,
Code: Select all
Scene.addPolygon{surfaces := [[[x - Start surface one,y - Start surface one]~[x - End surface one, y - End surface one] ],[[x - Start surface two,y - Start surface two]~[x - End surface two, y - End surface two] ]]] }


It can be thought of as: surfaces(surface)(point)(x or y co-ord). So surfaces(2)(1)(0) would give the x co-ordinate of the second point on the third surface, surfaces(2)(1) would give the [x,y] array of co-ordinates of the second point on the third surface, surfaces(2) would give the array of all the points (which each have arrays of co-ordinates) on the third surface, surfaces would give the array of all the surfaces in the polygon (which each have arrays of points (which each have arrays of co-ordinates)).

Vecs was for 4.22 (no self intersecting polygons), and water.

Hopefully this helps :D
Mechanisms: 18 Mechanisms.
Thyme: Tutorial - Variables/Commands List.
Thymechanic
gradyfitz
 
Posts: 174
Joined: Tue Sep 01, 2009 8:33 am
Location: Victoria, Australia

Re: Predefined Polygons

Postby standardtoaster » Sat Dec 19, 2009 7:01 am

It actually doesn't matter whether or not you use vecs or surfaces. I've always preferred vecs.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Predefined Polygons

Postby Papriko » Sat Dec 19, 2009 12:30 pm

I am quite lazy about writing and almost everything else too, so I first tried standardtoaster's suggestion. That worked great to me. I was really able to create a Triangle! :D

Now I just have to find out how I can directly rotate things while creating, but I already know where I could look that up...

Thanks you both for the quick and good answers!
I am currently only using Phun 5.28 and not Algodoo. I would annoy the people on the Phun Forum and not here, but the Forum refused new registrations when I looked the last time.
Papriko
 
Posts: 29
Joined: Tue Nov 17, 2009 8:43 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron