Jump to content

Carving infinite spiral


Recommended Posts

Hi guys,
I try to carve an infinite golden Spiral. The final goal is to make an infinte zoom.
The spiral is build recursively in a for-loop.
Then I create some groups to carve each "iteration" successively.
This is where I get stuck. I can almost do it but I don't know how to keep the state of the shapes that have been already carved.
Don't know how to explain better. There is a file if some want to take a look.
I have tried different solutions including another forloop, but don't find the solution for now.
 

InfiniteSpiralCarve.JPG

InfiniteSpiralCarve.hipnc

Edited by flcc
Link to comment
Share on other sites

hm If we can make somehow in the loop prim-length and measure together ..
 

void adjustPrimLength(const int geo, prim; const float currentlength, targetlength)
{
    float diff = targetlength - currentlength;
    int points[] = primpoints(geo, prim);
    if(diff > 0)
    {
        vector posA = point(geo, "P", points[-2]);
        vector posB = point(geo, "P", points[-1]);
        vector posC = diff * normalize(posB-posA) + posB;
        int ptnum = addpoint(geo, posC);
        addvertex(geo, prim, ptnum);
    }
    else if(diff < 0)
    {
        vector lastpos = 0;
        float length = 0;
        int cut = 0;
        foreach(int idx; int pt; points)
        {
            vector pos = point(geo, "P", pt);
            if(idx > 0 && !cut)
            {
                float seglength = distance(pos, lastpos);
                if(length+seglength > targetlength)
                {
                    float frac = (targetlength-length)/seglength;
                    vector newpos = lerp(lastpos, pos, frac);
                    int ptnum = addpoint(geo, newpos);
                    for(int i=idx; i<len(points); i++)
                        removepoint(geo, points[i]);
                    addvertex(geo, prim, ptnum);
                    break;
                }
                length += seglength;
            }
            lastpos = pos;
        }
#include <groom.h>
adjustPrimLength(0, @primnum, @perimeter, @perimeter*chf("dist"));

@Aizatulin when he Have Time   ...he have those vex-tricks and knowledge  in the Little Finger :rolleyes:
@flcc I'm also interested in this ....

  • Thanks 1
Link to comment
Share on other sites

@Aizatulin
Thank you very much
Perfect, this is exactly what I was looking for.
I understand what you did but I don't think I could have done it by myself.
I'm not very comfortable with for loops.
I would have had a hard time doing it this way since, since I didn't even think of using my class attribute in the piece attribute field of the block end.
But now I got it ! Ahah

@Librarian
Thanks Tesan, it seems interesting, but I prefer a solution close to what I had already tried to implement.
But I'll take a look once I'm not in the rush anymore.

Edited by flcc
  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...