Saturday, February 5, 2011

More POV-ray and Pysanky

Continuing with the series of pysanky eggs I've been working on with Python and POV-ray - another week, another egg.  This one is a Lemko design.  The dots, I believe, represent stars.

Getting the crown and base was relatively easy, as it just required the correct positioning of a single stroke, then rotating it:

def makecrown(baseobj):
    crownstrokes = [baseobj]
    theta = STEP
    while theta < 360.0:
        crownstrokes.append(pov.Object(baseobj,
                            rotate = (0.0, theta, 0.0)))
        theta += STEP
    return pov.Union(*crownstrokes)

In this case, step = 360.0/24.0.

Likewise, I have a function for the dots that made them easier to place:

def movedot(basedot, xtheta, ytheta):
    dot = pov.Object(basedot, rotate = (xtheta, ytheta, 0.0))
    return pov.Object(dot, translate = (0.0, 1.0, 0.0))

Ultimately, I'd like to get enough egg designs coded to put together some sort of scene in POV-ray dedicated to the eggs.  The following two scenes show what I have so far:

If I can identify a few more attractive, computationally friendly designs, I should be able to come up with enough eggs for a decent POV-ray egg scene.  In the meantime, thanks for having a look.

4 comments:

  1. Hey ,
    I was googling "povray python" and ended up here....so my comment or question is...is there a one to one correspondence? can I just say I am going to do my scenes just using python to generate the povray files no matter how involved the scene? ....and if so..is there a manual or something...
    Cheers

    ReplyDelete
  2. @The Great - you know, I'm really a dilettante. That disclaimer made, AFAIK the Active State recipe and associated project are the readily available Python libraries for POV-ray. I've just been patching that as needed to produce the Pov-ray Scene Description Language (SDL). It's brief and the code itself is the manual.

    I have found that there isn't a one to one correspondence. At least not in the ad hoc manner that I've been patching the recipe. Sometimes it's easier just to translate some list into a string of SDL code rather than approach the problem more elegantly. That's what I've been doing a lot of.

    The Active State recipe is a starting point. I've never done a highly involved scene, but I think you would have to add a lot to that recipe to cover all your bases.

    Hope this helps a little.

    Carl T.

    ReplyDelete
  3. Thanks Carl,
    Let me showcase my ignorance, I spent a good 15 minutes googling AFAIK and python together till I realized that AFAIK is not some kind of psychedelic python-povray project but "as far as I know" (and they say the Internet is not educational :) ). That resolved this brings me to the next items " The active State recipes and associated projects": where are they? are they these postings? (I know I know, I am slow).
    I use povray sporadically to create semi technical illustrations (loops, symmetries etc) and I am always struggling because I would love to use python style loops and conditionals.
    In any case thanks for your response and I will try to study the code in your postings
    Cheers
    Gino "The Great & Confused"

    ReplyDelete
  4. Gino, sorry, I was in a hurry and wanted to get back to you. The POV-Ray recipe link is here:

    http://code.activestate.com/recipes/205451-povray-for-python/

    The project is here (I believe this is related to the recipe):

    http://arrowtheory.com/software/python/pypov/index.html

    I added an Object method and a Prism method in a couple of my posts:

    http://pyright.blogspot.com/2010/12/more-pov-ray.html

    http://pyright.blogspot.com/2011/01/prims-and-trigonometric-shapes-pov-ray.html

    I use AFAIK and IIRC a lot. IIRC means "if I recall correctly". Apologies for the shorthand and the confusion.

    Carl T.

    ReplyDelete