Cylindrical Phyllotaxy Help!

   894   2   1
User Avatar
Member
355 posts
Joined: 11月 2015
Offline
Hi guys, I've been reading The Algorithmic Beauty of Plants(abop) and trying to implement the cylindrical phyllotactic algorithm (USING VEX, NOT L-SYSTEMS) to construct things like parametric pineapples. However, the math and formula explanations is over my head! I understand how to implement the planar phyllotaxy but when it gets to the cylindrical version, the encyclic and angular displacement stuff is over my head and it all goes fuzzy from there.

Anyone willing to help me implement this in VEX by assisting with the math, I'd very very much appreciative and I've also attached the phyllotaxy chapter of the book. Thanks again.

Attachments:
algorithmic_beauty_of_plants_phyllotaxy-ch4.pdf (2.5 MB)

hou.f*ckatdskmaya().forever()
User Avatar
Member
117 posts
Joined: 8月 2017
Offline
if you have points "you have everything" I think so .. 'Try' Play a little bit ... with 137.5◦
float VanDerCorpus(int n; int base)
{
    float invBase = 1.0f / float(base);
    float denom   = 1.0f;
    float result  = 0.0f;

    for(int i = 0; i < 32; ++i)
    {
        if(n > 0)
        {
            denom   = float(n) % 2.0f;
            result += denom * invBase;
            invBase = invBase / 2.0f;
            n       = int(float(n) / 2.0f);
        }
    }

    return result;
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
vector2 HammersleyNoBitOps(int i; int N)
{
    return set(float(i)/float(N), VanDerCorpus(i, 2));
}
vector ImportanceSampleGGX(vector2 Xi;vector N;float roughness)
{
    float a = roughness*roughness;

    float phi = 2.0 * PI * Xi.x;
    float cosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a*a - 1.0) * Xi.y));
    float sinTheta = sqrt(1.0 - cosTheta*cosTheta);

    // from spherical coordinates to cartesian coordinates
    vector H;
    H.x = cos(phi) * sinTheta;
    H.y = sin(phi) * sinTheta;
    H.z = cosTheta;

    // from tangent-space vector to world-space sample vector
    vector up        = abs(N.z) < 0.999 ? set(0.0, 0.0, 1.0) : set(1.0, 0.0, 0.0);
    vector tangent   = normalize(cross(up, N));
    vector bitangent = cross(N, tangent);

    vector sampleVec = tangent * H.x + bitangent * H.y + N * H.z;
    return normalize(sampleVec);
}
int n = chi("num");
for(int i=0;i<n;i++){
    int test = i;
    vector2 xy = HammersleyNoBitOps(test,n);
    vector testNormal = chv("normal");
    vector newpos = ImportanceSampleGGX(xy,testNormal, chf("roughtness"));
    addpoint(geoself(),newpos);
}

Attachments:
vfgbbb.jpg (505.4 KB)

Conservation of Momentum
User Avatar
Member
355 posts
Joined: 11月 2015
Offline
cncverkstad
if you have points "you have everything" I think so .. 'Try' Play a little bit ... with 137.5◦
float VanDerCorpus(int n; int base)
{
    float invBase = 1.0f / float(base);
    float denom   = 1.0f;
    float result  = 0.0f;

    for(int i = 0; i < 32; ++i)
    {
        if(n > 0)
        {
            denom   = float(n) % 2.0f;
            result += denom * invBase;
            invBase = invBase / 2.0f;
            n       = int(float(n) / 2.0f);
        }
    }

    return result;
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
vector2 HammersleyNoBitOps(int i; int N)
{
    return set(float(i)/float(N), VanDerCorpus(i, 2));
}
vector ImportanceSampleGGX(vector2 Xi;vector N;float roughness)
{
    float a = roughness*roughness;

    float phi = 2.0 * PI * Xi.x;
    float cosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a*a - 1.0) * Xi.y));
    float sinTheta = sqrt(1.0 - cosTheta*cosTheta);

    // from spherical coordinates to cartesian coordinates
    vector H;
    H.x = cos(phi) * sinTheta;
    H.y = sin(phi) * sinTheta;
    H.z = cosTheta;

    // from tangent-space vector to world-space sample vector
    vector up        = abs(N.z) < 0.999 ? set(0.0, 0.0, 1.0) : set(1.0, 0.0, 0.0);
    vector tangent   = normalize(cross(up, N));
    vector bitangent = cross(N, tangent);

    vector sampleVec = tangent * H.x + bitangent * H.y + N * H.z;
    return normalize(sampleVec);
}
int n = chi("num");
for(int i=0;i<n;i++){
    int test = i;
    vector2 xy = HammersleyNoBitOps(test,n);
    vector testNormal = chv("normal");
    vector newpos = ImportanceSampleGGX(xy,testNormal, chf("roughtness"));
    addpoint(geoself(),newpos);
}


@cncverkstad thanks much, I’ll tun through soon and let you know the results; this is much appreciated!
Edited by traileverse - 2021年11月16日 14:20:54
hou.f*ckatdskmaya().forever()
  • Quick Links