Automatic Weave Generator (doesn't work yet)
View previous topic | View next topic >
Post new topic Reply to topic
M.A.I.L. Forum Index -> Weaves Discussion
   
Author Message

Joined: October 29, 2008
Posts: 134
Submissions: 9
Location: Texas, USA

Automatic Weave Generator (doesn't work yet)
Reply with quote
Posted on Mon Nov 10, 2008 7:33 am
Link to Post: Link to Post

Well, I've been thinking about this for a while now and not doing anything until tonight, when I spent a few hours (well several) coding up a simple and crude initial attempt at an automatic weave generator. As you can see in the photo, it has a few wee flaws like melting rings together and not spreading them out correctly, but aside from that it's a good first shot at it.



The code is entirely written in POV-Ray, so no other languages to learn, just a ton of #declare and #while statements forming nested loops that do all the magic. I'm having fun playing around with it, but if there are any POV-Ray-Heads out there who would love to grab it and make it into the automatic weave generator that it really should and wants to be, just let me know. I can email the code out or maybe even just paste it into a forum message if that doesn't constitute cruel and unusual abuse of forum ettiquite.

Just another strange thing from the very strange mind of Inventor, heh! Smile

Joined: April 15, 2002
Posts: 1823
Submissions: 1
Location: Calgary, AB. Canada.

Reply with quote
Posted on Mon Nov 10, 2008 3:06 pm
Link to Post: Link to Post

Like I said to you on IRC the other day.. fused rings could be solved.. if there was a way to detect intersections.

I know there is a way to detect them manually, by intersecting every ring with every other, viewing the images, and the accepting or rejecting them based on whether there's anything visible or not. (If there's something visible, that is where two rings overlap).

But, to do this automatically would be the key. You'd probably need some external script. Could be easy. Maybe even just check for file size, or a bit compare. An all black image should be tiny. An image with any white in it at all would have to be bigger filesize and a different bit compare.

If that works, you could just have POVray run a random script creating a new weave of, whatever, 15 or 30 randomly situated and oriented rings, and then do your rings^2 number of comparisons, spit those into a new directory for every arrangement.. and have that chug along overnight for a week or two. Then, run the external script to sort through them and flag for you the ones that past the zero-overlap test.

Or, the external script could recode the file to remove one of the overlapped rings, as long as it didn't break the weave into two separate patches.

You'd start to have an infinite monkeys syndrome though. Sure, an infinite amount of monkeys would write Romeo and Juliette, but, the tiniest flaw and you end up with garbage. Might actually require an infinite amount of rendering to create anything much of use. Using larger AR rings would probably help, just to cut down on the odds of intersections.

Is still a fascinating endeavor.

An evolutionary model would be interesting too. As in, if some rings meet it, keep them, randomly mutate a few others, see if they "survive" the intersection test, if so, randomly mutate a few others...

Add in some bonus constraints.. Let it run for a year and see what it creates Smile

Joined: October 29, 2008
Posts: 134
Submissions: 9
Location: Texas, USA

Reply with quote
Posted on Mon Nov 10, 2008 4:58 pm
Link to Post: Link to Post

Yes, Cynake, you are on-spot on all points. I found that adjusting the AR of the rings minimized the fuzing, but I still have no test for whether a ring is inside of another ring or not, and no test for fuzed rings. The biggest problem as you mention is the monkeys on the typewriters problem. I may be able to apply some symmetry rules to help with that. Anyway, I'm having a good time playing with it!

Joined: June 26, 2008
Posts: 308
Submissions: 2

Reply with quote
Posted on Mon Nov 10, 2008 8:03 pm
Link to Post: Link to Post

Just a small thing that I found out a while ago while investigating a weave modeler... if you're doing your rings as true toruses, it's almost impossible to compute intersections/collisions. I don't remember why, partly because the math involved went WAY over my head; but it was enough to make me give up on the problem at least at that time.

Joined: October 29, 2008
Posts: 134
Submissions: 9
Location: Texas, USA

Reply with quote
Posted on Mon Nov 10, 2008 10:42 pm
Link to Post: Link to Post

Aha, well no wonder I can't think of a way to do it, it's too difficult as it iis! Well, I am just playing around to see what happens next!

Joined: October 29, 2008
Posts: 134
Submissions: 9
Location: Texas, USA

Reply with quote
Posted on Tue Nov 11, 2008 5:44 am
Link to Post: Link to Post

Here is an MPG movie that I made with 100 weaves shown one per second:

http://www.freedomodds.com/chainmaille/movies/WeaveMaker10.MPG

Sorry if the rings are a bit speckled, I'm not sure if that's from the .mov to .mpg converter or the lighting being a bit too bright. Anyway, there it is. Smile

Joined: December 23, 2007
Posts: 41
Submissions: 14

Reply with quote
Posted on Wed Nov 12, 2008 3:55 pm
Link to Post: Link to Post

I see one image for 1 min. and 40 seconds and a half second shot of another image. The first image doesn't look to be any weave, maybe it was supposed to be of euro 6 in 1? Not sure what the last image was.

I haven't dabbled much in POV-RAY, really need to sit down someday and play with it.

Joined: October 29, 2008
Posts: 134
Submissions: 9
Location: Texas, USA

Reply with quote
Posted on Wed Nov 12, 2008 6:38 pm
Link to Post: Link to Post

I don't know what that problem is, I generated a .mov file in POV-Ray but it wouldn't load din QuickTime so I converted it to MPG and it worked. Perhaps I will post the source code if youi like and you can run it yourself?

Joined: October 29, 2008
Posts: 134
Submissions: 9
Location: Texas, USA

Reply with quote
Posted on Wed Nov 12, 2008 8:04 pm
Link to Post: Link to Post

OK, I made time to post the code, which is here:

http://www.freedomodds.com/chainmaille/code/WeaveMaker11.pov

Actually this code is a hint different, showing nice bronze colored rings. You are free to do whatever you wish with the code, just keep my name in the credits. Enjoy!

Joined: August 10, 2005
Posts: 7098
Submissions: 337
Location: UK

Reply with quote
Posted on Thu Nov 13, 2008 8:41 am
Link to Post: Link to Post

Well done you! Smile


Maille Code
V2.0 T7.3 R5.4 Ep Feur MAg/Cu Wm$ Cbjpw$ G0.5/3.0 I1.5/12.0 N322.150 Pajs Dacdjsw Xa7g631p4t24w64 S88 Hipsu

Joined: October 29, 2008
Posts: 134
Submissions: 9
Location: Texas, USA

Reply with quote
Posted on Thu Nov 13, 2008 12:47 pm
Link to Post: Link to Post

Thanks, Legba3, though it is really just a pseudo-random generator. I tried doing stuff like letting the rings pull each other together or rotate, but eventually discovered that I got better results by carefully choosing the random generation parameters.

Later, if I or someone else can come up with a POV-Way (pun intended) of detecting intersecting and/or fused rings, then we can do some evolutionary code like Cynake mentioned. I think such things are possible but not easy. As it is with just random generation, about 5% of the designs look at least close to being practical and useful such that a creative ring-wiggler could use it as inspiration for a new weave. But I'm not suggesting that this thing just spews out new weaves, not by a long shot - more of clues or ideas for weavers to imagine.

Note that to get the movie you must set up POV-Ray for animation with 101 frames (or however many frames you want, up to 1,000). Then the number in blue is the seed value that goes into the random number seed function so that you can re-create the same weave if you like.

I don't know if I'll work on it anymore, but if smarter POV-Heads than me toss out some good ideas of how to improve it, I'll be happy to be the code-monkey and implement some or all of those ideas. Hope you like the program, it was fun to write and I enjoy watching the weave-movie! Cheers!

Joined: October 29, 2008
Posts: 134
Submissions: 9
Location: Texas, USA

Reply with quote
Posted on Thu Nov 13, 2008 5:24 pm
Link to Post: Link to Post

To test the weave generator I reviewed the 100 weave movie and tried to make a weave. My second attempt worked, which is Weave890 as shown from the movie below.



When woven in 12 ga 1/2" rings and photographed with my poor little phonecam (sorry about image quality but you can see it well enough), it looks like this:



Now I'm not saying that this weave is new or useful or interesting, I'm just testing out the weave generator to see if it can actually produce real chainmaille weaves and not just fantasy images of melted and floating rings. So there you go, at least one out of 100 tries did *something* weave-worthy at least.

Hmmm, next I think I will play with the movie display so that it rotates each weave or something like that, I dunno. Still just playing around and having fun - and isn't that what it's all about anyway? Smile

Joined: June 02, 2007
Posts: 1523
Submissions: 9
Location: Bruges, Belgium

Reply with quote
Posted on Thu Nov 13, 2008 7:53 pm
Link to Post: Link to Post

That's looking like a 'brute force' way to create weaves. Razz
But that's a good thing, isn't it? Coif Cool Smiley


Horum omnium fortissimi sunt Belgae. [Of all these the Belgians are the bravest/strongest.]
- Gaius Iulius Caesar, De Bello Gallico I 3

Joined: October 29, 2008
Posts: 134
Submissions: 9
Location: Texas, USA

Reply with quote
Posted on Thu Nov 13, 2008 8:16 pm
Link to Post: Link to Post

Haha, yes, it is definitely "brute force", just position rings randomly and see if one percent of them does anything, and maybe one percent of *those* is unique. This project could certainly use some smarts to cut down on the junk and get more of the useful weaves. Gathering what folks are saying, though, it's a difficult task to undertake and I am just getting started.

I tried to add a little smarts by tuning the random number ranges and making a user-defined number of segments that repeat longitudinally. Also I'm learning that the user can add human smarts, for example when rings are fuzed together, making the choice as to which way to orient the real rings. Plus now the movie rotates the weave so you can see it from all angles, which helps to reject the junk weaves and visualize the good ones.

All in all, though, right now it's crude, rude, and socially unacceptable, but then so am I, haha! At least I'm having fun: programming + coffee + chainmaille = fun.

Joined: October 29, 2008
Posts: 134
Submissions: 9
Location: Texas, USA

Reply with quote
Posted on Fri Nov 14, 2008 5:43 am
Link to Post: Link to Post

For anyone following this thread, I have a pleasant progress report. I did a lot of reading on the POV-Ray documentation pages, which are very well done by the way, and I figured out a way to test for *both* fuzed rings and linked rings.

There is a function called "inside". You pass it a defined object and a vector, and it tells you if the vector points to a location inside the object. So then I had to figure out the vector transformations of a ring and make a deeply nested loop to compare all the rings, but there you have it, a way to do those two tests.

So I put these tests into the program and stuck a huge while loop around the whole thing. Now it rejects thousands of weaves before accepting one and 80% of the time it is a valid weave. I ran a test case on 11 weaves in 5 minutes on my slow old Mac and it generated eight valid weaves (of three types) plus two bad ones. Now the weaves it generates are not all that exciting, especially as it prefers to generate simple chain link that's all twisted up, lol, but this is a promising step forward from what you have read so far.

Up next I am going to add other ring sizes and wire diameters to give it some more degrees of freedom in creating weaves, and then perhaps later I'll put Cynake's idea of an evolutionary code into place. After all, it is definitely a monkey-typewriter problem still, even with smart tests for viable weaves.

So... progress! Yay! Smile

Post new topic Reply to topic
Jump to:  
Page 1 of 3. Goto page 1, 2, 3  Next
All times are GMT. The time now is Fri Apr 03, 2020 8:30 pm
M.A.I.L. Forum Index -> Weaves Discussion
Display posts from previous: