POV-Ray : Newsgroups : povray.advanced-users : Pattern showing *change* in slope Server Time
3 Jul 2024 06:14:33 EDT (-0400)
  Pattern showing *change* in slope (Message 7 to 16 of 26)  
<<< Previous 6 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: SharkD
Subject: Re: Pattern showing *change* in slope
Date: 28 Aug 2009 10:33:34
Message: <4a97eabe$1@news.povray.org>
Warp wrote:
> Jaime Vives Piqueres <jai### [at] ignoranciaorg> wrote:
>> // sloped texture with autoilluminated finish
>> #declare t_terrain_slope=
>> texture{
>>   pigment{
>>    slope y
> 
>   That shows the slope of the heightfield, not the *change* in slope,
> which is a bit more involved (it would require the derivative of the
> function which indicates the slope of the heightfield; since the slope
> function is the derivative of the heightfield function, the change in
> slope would thus be the double derivative of the heightfield function).
> 
>   Maybe the original poster really wanted to actually see the slope,
> rather than the change in slope, in which case your answer would be
> the correct one.
> 

Is there a function in POV that will allow me to automatically take the 
derivative of another function?

-Mike


Post a reply to this message

From: Warp
Subject: Re: Pattern showing *change* in slope
Date: 28 Aug 2009 11:12:05
Message: <4a97f3c5@news.povray.org>
SharkD <mik### [at] gmailcom> wrote:
> Nope. I want the double derivative.

  Then your only option is to generate the heightfield using a function
and then use the double derivative of that function with respect to x and
another with respect to y and combine them appropriately to create the
desired pattern, which you then can use to create the pigment.

-- 
                                                          - Warp


Post a reply to this message

From: Warp
Subject: Re: Pattern showing *change* in slope
Date: 28 Aug 2009 11:13:36
Message: <4a97f41f@news.povray.org>
SharkD <mik### [at] gmailcom> wrote:
> Is there a function in POV that will allow me to automatically take the 
> derivative of another function?

  Calculating the derivative of a function analytically is not trivial
and has such low demand that povray obviously doesn't offer such a thing.

  A numerical approximation could be easier, but still the demand is so
low that no such luck.

  But I think the user-defined functions are expressive enough for you to
do it in SDL.

-- 
                                                          - Warp


Post a reply to this message

From: SharkD
Subject: Re: Pattern showing *change* in slope
Date: 28 Aug 2009 11:52:04
Message: <4a97fd24$1@news.povray.org>
Warp wrote:
> SharkD <mik### [at] gmailcom> wrote:
>> Is there a function in POV that will allow me to automatically take the 
>> derivative of another function?
> 
>   Calculating the derivative of a function analytically is not trivial
> and has such low demand that povray obviously doesn't offer such a thing.
> 
>   A numerical approximation could be easier, but still the demand is so
> low that no such luck.
> 
>   But I think the user-defined functions are expressive enough for you to
> do it in SDL.
>


Post a reply to this message

From: SharkD
Subject: Re: Pattern showing *change* in slope
Date: 28 Aug 2009 11:52:30
Message: <4a97fd3e@news.povray.org>
Warp wrote:
>   But I think the user-defined functions are expressive enough for you to
> do it in SDL.
> 

OK, so how would I go about doing it?

-Mike


Post a reply to this message

From: SharkD
Subject: Re: Pattern showing *change* in slope
Date: 28 Aug 2009 12:05:34
Message: <4a98004e$1@news.povray.org>
clipka wrote:
> SharkD schrieb:
>> How can I create a pattern that shows the *change* in slope of a 
>> heightfield. I.e., brighter where the "curvature" is greater.
> 
> You can create this from the image you use for the height field
> 
> To begin with, make a pigment from the image; make from that a function F.
> 
> Now, create a function G computing the curvature from five function 
> values from F, spaced apart by (at least) 1/BITMAP_SIZE, to compute the 
> "difference in difference" both vertically and horizontally:

OK, here's what I have:

//START
#local hf_function1 = function {pigment {hf_pigment3}}
#local dv_D = 1/1024;
#local dv_Sqr = function(x) {x * x}
#local dv_G = function(x,y,z)
{
	sqrt
	(
		dv_Sqr(hf_function1(x - dv_D,y,z) + hf_function1(x + dv_D,y,z) - 2 * 
hf_function1(x,y,z))
		dv_Sqr(hf_function1(x,y - dv_D,z) + hf_function1(x,y - dv_D,z) - 2 * 
hf_function1(x,y,z))
	)
}
//END

However, I get the error: "Parse Error: Expected '.', + found instead"

-Mike


Post a reply to this message

From: Warp
Subject: Re: Pattern showing *change* in slope
Date: 28 Aug 2009 12:09:26
Message: <4a980135@news.povray.org>
SharkD <mik### [at] gmailcom> wrote:
> Warp wrote:
> >   But I think the user-defined functions are expressive enough for you to
> > do it in SDL.
> > 

> OK, so how would I go about doing it?

http://en.wikipedia.org/wiki/Derivative

-- 
                                                          - Warp


Post a reply to this message

From: SharkD
Subject: Re: Pattern showing *change* in slope
Date: 28 Aug 2009 12:10:02
Message: <4a98015a$1@news.povray.org>
clipka wrote:
>   sqrt(
>     Sqr( F(x-D,y,z) + F(x+D,y,z) - 2*F(x,y,z) ) // squared curvature X
>     Sqr( F(x,y-D,z) + F(x,y-D,z) - 2*F(x,y,z) ) // squared curvature Y
>   )

Also, there's supposed to be an operator between the first and second 
instances of the function "Sqr". Which operator is it?

-Mike


Post a reply to this message

From: SharkD
Subject: Re: Pattern showing *change* in slope
Date: 28 Aug 2009 12:16:08
Message: <4a9802c8@news.povray.org>
Warp wrote:
>> OK, so how would I go about doing it?
> 
> http://en.wikipedia.org/wiki/Derivative
> 

Please point me to the part where it describes POV SDL.

Thanks.

-Mike


Post a reply to this message

From: clipka
Subject: Re: Pattern showing *change* in slope
Date: 28 Aug 2009 12:31:00
Message: <4a980644$1@news.povray.org>
SharkD schrieb:
> clipka wrote:
>>   sqrt(
>>     Sqr( F(x-D,y,z) + F(x+D,y,z) - 2*F(x,y,z) ) // squared curvature X
>>     Sqr( F(x,y-D,z) + F(x,y-D,z) - 2*F(x,y,z) ) // squared curvature Y
>>   )
> 
> Also, there's supposed to be an operator between the first and second 
> instances of the function "Sqr". Which operator is it?

Oops, sorry - should be "+".

The idea behind it is that each terms inside the Sqr() computes the 
curvature in a particular dimension; if you interpret that as a vector, 
the sqrt(Sqr()+Sqr()) computes the "absolute" of the curvature.


Post a reply to this message

<<< Previous 6 Messages Goto Latest 10 Messages Next 10 Messages >>>

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