POV-Ray : Newsgroups : povray.newusers : Candy cane torus pattern Server Time
27 Nov 2024 12:34:16 EST (-0500)
  Candy cane torus pattern (Message 1 to 3 of 3)  
From: hrisedorph
Subject: Candy cane torus pattern
Date: 20 Dec 2002 17:15:09
Message: <web.3e0394626c2b88df6e6484130@news.povray.org>
I've looked in the documentation, on these newsgroups, and tried several
different mappings...

What I want to do is make a candy cane. I set up the gradient map for the
straight parts, but in the hook part, I can't get it to look right. I
*could* just use one overall pattern, but it's not really ... it just sort
of goes diagonally across the ring instead of winding around it. I'm pretty
new to this, so when I found a news post that basically tells exactly how
to make it, I didn't understand what was meant.

The post is at:
http://news.povray.org/povray.programming/17265/110301/#110301

Here's my code (replace the ! with vector brackets ... it was doing
something weird with them for some reason):

// obligatory header code
#include "textures.inc"
#include "finish.inc"
background { color rgb 1 }
camera { location <0,10,3> look_at <0,0,3> }
light_source { <5,5,3> color rgb 1 }

// size settings
#declare CC_t = .25;
#declare CC_a = 1.0;
#declare CC_l = 6.5;

// working, nice looking, stripes for the straight candy pieces
#declare CC_stripe = texture {
  pigment {
    gradient x+z
    color_map {
          [0.0000 color rgb 1]
          [0.1117 color rgb 1]
          [0.1117 color red 0.74 green 0.00 blue 0.00]
          [0.4117 color red 0.74 green 0.00 blue 0.00]
          [0.4117 color rgb 1]
          [0.6350 color rgb 1]
          [0.6350 color red 0.74 green 0.00 blue 0.00]
          [0.6550 color red 0.74 green 0.00 blue 0.00]
          [0.6550 color rgb 1]
          [0.8683 color rgb 1]
          [0.8683 color red 0.74 green 0.00 blue 0.00]
          [0.8883 color red 0.74 green 0.00 blue 0.00]
          [0.8883 color rgb 1]
          [1.0000 color rgb 1]
    }
  }
  finish { Phong_Dull }
}

// this part I don't know how to do
#declare CC_stripe_arc = texture { ? ? ? }

// the CSG makes a nice looking candy cane shape
#declare CandyCane = union {
  difference {
    torus { CC_a, CC_t texture { CC_stripe_arc } }
    box {
!CC_a+CC_t+.01,-1*(CC_t+.01),0!,!-1*(CC_a+CC_t+.01),CC_t+.01,CC_a+CC_t+.01!
}
  }
  cylinder { !CC_a,0,-.001!,!CC_a,0,CC_l!,CC_t texture { CC_stripe } }
  cylinder { !-1*CC_a,0,-.001!,!-1*CC_a,0,CC_a/2!,CC_t texture { CC_stripe }
}
  sphere { !-1*CC_a,0,CC_a/2!,CC_t texture { CC_stripe } }
  sphere { !CC_a,0,CC_l!,CC_t texture { CC_stripe } }
}

// put the test object in the scene
object { CandyCane }

I tried using the function code put on the news post that was indicated by
the URL above, but it keeps asking for a parameter or float constant, and
when I put in fmod 1.0 or 1.0 it tells me it wasn't expecting a float
constant. I tried to follow the function documentation ... function { x + y
+ z } is listed in the documentation, but function { /* complex function
using atans */ } gave a parsing error. It's frustrating when all I want to
do is match the stripes on the torus to the straight pieces.

(This is my first post so if my ettiquette is bad let me know ... I have to
use web view because I only have 'net at work so I'm limited to no
attachments)


Post a reply to this message

From: Christopher James Huff
Subject: Re: Candy cane torus pattern
Date: 20 Dec 2002 18:08:43
Message: <chrishuff-C6FB3F.18033620122002@netplex.aussie.org>
In article <web.3e0394626c2b88df6e6484130@news.povray.org>,
 "hrisedorph" <nomail@nomail> wrote:

> What I want to do is make a candy cane. I set up the gradient map for the
> straight parts, but in the hook part, I can't get it to look right. I
> *could* just use one overall pattern, but it's not really ... it just sort
> of goes diagonally across the ring instead of winding around it. I'm pretty
> new to this, so when I found a news post that basically tells exactly how
> to make it, I didn't understand what was meant.

Try this:
torus {1, 0.2
    texture {
        pigment {
            function {(atan2(1 - sqrt(x*x + z*z), y) + 6*atan2(z, x))/pi}
            color_map {
                [0 color rgb 0]
                [1 color rgb < 1, 0, 0>]
            }
        }
    }
}

Or a macro to make adjusting it easier:
#macro TorusSpiralPtrn(MajorRadius, Stripes, Spirals)
    function {
        (atan2(MajorRadius - Stripes*sqrt(x*x + z*z), y) + 
Spirals*atan2(z, x))/pi
    }
#end

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Ken
Subject: Re: Candy cane torus pattern
Date: 20 Dec 2002 21:16:42
Message: <3E03CFA7.C4F77031@pacbell.net>
Christopher James Huff wrote:

> Try this:

Or, a candycane you shared with me about 3 years ago -

#declare CandyCane =
union {
 #declare ccTex =
 texture {
  pigment  {
   radial
   frequency 2
   color_map {
    [ 0.0 color rgb < 0.933333, 0.933333, 0.933333 > ]
    [ 0.475 color rgb < 0.933333, 0.933333, 0.933333 > ]
    [ 0.525 color rgb < 0.937255, 0.121569, 0.113725 > ]
    [ 1.0 color rgb < 0.937255, 0.121569, 0.113725 > ]
   }
  }
 }
 //***User Parameters
 #declare stickParts = 100;
 #declare stickLen = 2;
 #declare totalRot = 360;
 //***
 sphere  { < 0, 0, 0 >, 0.1 texture {ccTex}}
 //***Loop Initialization
 #declare partRot = totalRot/stickParts;
 #declare k=0;
 #while(k < stickParts)
  #declare segSt = < 0, stickLen/stickParts*k, 0 >;
  #declare segEnd = < 0, stickLen/stickParts*(k+1), 0 >;

  cylinder {segSt, segEnd, 0.1 texture {ccTex rotate < 0, partRot*k, 0>}}

  #declare k=k+1;
 #end

 //***User Parameters
 #declare curveParts = 100;
 #declare curveArc = 200;
 #declare curveRad = 0.5;
 //***
 //***Loop Initialization
 #declare curveLen = curveRad*2*pi*(curveArc/360);
 #declare k=0;
 #while(k < curveParts)

  sphere {< 0, 0, 0 >, 0.1
   texture {ccTex rotate < 0, partRot*k, 0>}
   translate < -(curveRad), 0, 0>
   rotate < 0, 0, -k*(curveArc/curveParts)>
   translate < curveRad, stickLen, 0>
  }

  #declare k=k+1;
 #end
}

-- 
Ken Tyler


Post a reply to this message

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