POV-Ray : Newsgroups : povray.newusers : Bobby hat Server Time
29 Jul 2024 04:20:22 EDT (-0400)
  Bobby hat (Message 1 to 3 of 3)  
From: Kari Ojala
Subject: Bobby hat
Date: 11 Nov 2006 11:29:38
Message: <Xns9878BC4562324kariojalaikifi@203.29.75.35>
I'm trying to do the bobby hat -thing and my functions give extraneous 
sharp edges. The following script  has commented out the kind of thing I'm 
looking for (made with a pattern) and the problematic line uncommented.


#include "colors.inc"

global_settings {assumed_gamma 2.4 }
  
plane {
  y, -1.8
  pigment { checker DarkTan DarkOliveGreen }
  }

light_source { <5, 14, -8> color White }

camera {
  location <0, 0, -4>
  look_at 0 angle 46  
  rotate x*7 rotate y*6 }

#declare ndist = function (x,y) {
  sqrt(pow(x,2)+pow(y,2))/sqrt(2)
  }

height_field  {
  function  100, 100 {
  // pattern { waves scale .1 }
  1+cos(2*pi*ndist(x,y))
  }
  pigment { DarkOrchid }
  translate -.5
  scale <2, .5, 2>
  }


Post a reply to this message

From: Tek
Subject: Re: Bobby hat
Date: 13 Nov 2006 10:11:48
Message: <45588b34$1@news.povray.org>
I'm not sure I understand what that's supposed to do, but I'll have a go at 
fixing it. I think the ranges of your numbers are wrong, is this more the 
effect you were after?

height_field  {
  function  100, 100 {
  // pattern { waves scale .1 }
  .5+.5*cos(2*pi*ndist(x*2-1,y*2-1))
  }
  pigment { DarkOrchid }
  translate -.5
  scale <2, .5, 2>
  }

What I've done is change x & y to (x*2-1,y*2-1), so they go from -1 to 1 
(heightfields use 0 to 1) and change the output so it's between 0 and 1 
(.5+.5*cos), your original function was outputting values between 0 and 2 
(1+cos) so when it went above 1 it wrapped round to zero again, hence a 
sharp change.

Hope that helps :)
-- 
Tek
http://evilsuperbrain.com

"Kari Ojala" <kar### [at] ikifi> wrote in message 
news:Xns9878BC4562324kariojalaikifi@203.29.75.35...
>
> I'm trying to do the bobby hat -thing and my functions give extraneous
> sharp edges. The following script  has commented out the kind of thing I'm
> looking for (made with a pattern) and the problematic line uncommented.
>
>
> #include "colors.inc"
>
> global_settings {assumed_gamma 2.4 }
>
> plane {
>  y, -1.8
>  pigment { checker DarkTan DarkOliveGreen }
>  }
>
> light_source { <5, 14, -8> color White }
>
> camera {
>  location <0, 0, -4>
>  look_at 0 angle 46
>  rotate x*7 rotate y*6 }
>
> #declare ndist = function (x,y) {
>  sqrt(pow(x,2)+pow(y,2))/sqrt(2)
>  }
>
> height_field  {
>  function  100, 100 {
>  // pattern { waves scale .1 }
>  1+cos(2*pi*ndist(x,y))
>  }
>  pigment { DarkOrchid }
>  translate -.5
>  scale <2, .5, 2>
>  }
>
>


Post a reply to this message

From: Kari Ojala
Subject: Re: Bobby hat
Date: 14 Nov 2006 08:40:49
Message: <Xns987B9FAB048FDkariojalaikifi@203.29.75.35>
"Tek" <tek### [at] evilsuperbraincom> wrote in news:45588b34$1@news.povray.org:
> 
> What I've done is change x & y to (x*2-1,y*2-1), so they go from -1 to
> 1 (heightfields use 0 to 1) and change the output so it's between 0
> and 1 (.5+.5*cos), your original function was outputting values
> between 0 and 2 (1+cos) so when it went above 1 it wrapped round to
> zero again, hence a sharp change.
> 
> Hope that helps :)

Absolutely. It looked even better than I remembered it would. The thing I 
remember is that this is not the first time I've had problems with ranges. 
Just like in a supermarket: I go looking for juice and come out drinking 
pure concentrate.

Cheers, 

Kari O.


Post a reply to this message

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