POV-Ray : Newsgroups : povray.general : Hexagon pattern with 4 or 7 colors? : Re: Hexagon pattern with 4 or 7 colors? Server Time
23 Apr 2024 10:22:22 EDT (-0400)
  Re: Hexagon pattern with 4 or 7 colors?  
From: Bald Eagle
Date: 27 Apr 2018 20:05:01
Message: <web.5ae3b9b397bd16015cafe28e0@news.povray.org>
So, IRL is busy and chaotic, but here's what I have so far in case anyone can
point out some obvious mistakes.

Obviously I will try out other variations and source code functions...


#version 3.7;
global_settings {assumed_gamma 1.0}

#include "colors.inc"

sky_sphere {pigment {rgb <1, 1, 1>*0.2}}

camera {
   location <0, 0, -150>    // position & direction of view
  look_at  <0, 0, 0>
  right x*image_width/image_height           // horizontal size of view
  up y // vertical size of view
 }

light_source {<25, 25, -150> color White}






//From fnintern.cpp
/*
DBL f_hex_x(FPUContext *ctx, DBL *ptr, unsigned int fn); // 27
DBL f_hex_y(FPUContext *ctx, DBL *ptr, unsigned int fn); // 28

const Trap POVFPU_TrapTable[] =
{
    { f_hex_x,                   1 + 3 }, // 27
    { f_hex_y,                   1 + 3 }, // 28
};


DBL f_hex_x(FPUContext *ctx, DBL *ptr, unsigned int) // 27

{
    DBL x1,y1,x2,y2, th;
    x1=fabs(fmod(fabs(PARAM_X), sqrt(3.0))-sqrt(3.0)/2);
    y1=fabs(fmod(fabs(PARAM_Y), 3)-1.5);
    x2=sqrt(3.0)/2-x1;
    y2=1.5-y1;
    if ((x1*x1+y1*y1)>(x2*x2+y2*y2))
    {
        x1=x2;
        y1=y2;
    }
    if ((x1==0)&&(y1==0))
        PARAM_X=0.000001;
    th=atan2(y1,x1);
    if (th<M_PI/6)
        return(x1);
    else
    {
        x1=cos(M_PI/3)*x1+sin(M_PI/3)*y1;
        return(x1);
    }
}
*/

#declare S3 = sqrt(3.0);
#declare S32 = sqrt(3.0)/2;
#declare x1 = function (x) {abs(mod(abs(x), S3)-S32)}
#declare y1 = function (y) {abs(mod(abs(y), 3)-1.5)}
#declare x2 = function (x) {S32-x1(x)}
#declare y2 = function (y) {1.5-y1(y)}
#declare X0 = 0.000001;

#declare X1 = function (x, y) {select
((x1(x)*x1(x)+y1(y)*y1(y))-(x2(x)*x2(x)+y2(y)*y2(y)), x2(x), x1(x), x1(x))}
#declare Y1 = function (x, y) {select
((x1(x)*x1(x)+y1(y)*y1(y))-(x2(x)*x2(x)+y2(y)*y2(y)), y2(y), y1(y), y1(y))}
#declare Th = function (x, y) {select (X1(x1(x), y1(y))*Y1(x1(x), y1(y)),
atan2(Y1(x1(x), y1(y)), X0), atan2(Y1(x1(x), y1(y)), X1(x1(x), y1(y))),
atan2(Y1(x1(x), y1(y)), X0))}

#declare Hexagonal = function (x, y) {select(Th(X1(x1(x), y1(y)), Y1(x1(x),
y1(y)))-(pi/6), X1(x1(x), y1(y)), cos(pi/3)*Y1(x1(x), y1(y))+sin(pi/3)*Y1(x1(x),
y1(y)))}

#declare Hex = pigment {
 function {Hexagonal (x, y)}
 color_map {
  [0.00 rgb 0]
  [1.00 rgb 1]
 }
 scale 10
}

box {<1,1,0.0001>*-50, <1,1,0.0001>*50 pigment {Hex} }

/*
DBL f_hex_y(FPUContext *ctx, DBL *ptr, unsigned int) // 28
{
    DBL x1,y1,x2,y2, th;
    x1=fabs(fmod(fabs(PARAM_X), sqrt(3.0))-sqrt(3.0)/2);
    y1=fabs(fmod(fabs(PARAM_Y), 3)-1.5);
    x2=sqrt(3.0)/2-x1;
    y2=1.5-y1;
    if ((x1*x1+y1*y1)>(x2*x2+y2*y2))
    {
        x1=x2;
        y1=y2;
    }
    if ((x1==0)&&(y1==0))
        PARAM_X=0.000001;
    th=atan2(y1,x1);
    if (th<M_PI/6)
        return(y1);
    else
    {
        y1=-sin(M_PI/3)*x1+cos(M_PI/3)*y1;
        return(fabs(y1));
    }
}
*/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.