|
|
On 04/08/2016 02:24 PM, clipka wrote:
> Am 08.04.2016 um 09:49 schrieb Jaime Vives Piqueres:
>> El 08/04/16 a las 06:45, Cousin Ricky escribió:
>>> My instinct would be to avoid the analysis approach, and do sampling
>>> on the original function. That doesn't take a lot of sophisticated
>>> math. I can't even remember the chain rule without looking it up
>>> (and the last time I did so was, like, 2005), but I have used
>>> sampling to estimate normals on a form based on parametric functions.
>>> I did this for the smooth triangles of the elliptical toroids in
>>> RoundEdge. Normals, of course, can be easily converted to slopes.
>>>
>>
>> I'm still trying to grasp the concept of "sampling a function"... ho
w
>> I would do that? With another function? If someone can please post a
>> simple example...
>
> // Base function
> #declare Fn = function(x,y) { /* whatever */ }
>
> #declare EPSILON = 1e-6;
>
> // Approximate first derivatives along the x and y axes
> #declare Fn1X = function(x,y)
> { (Fn(x+EPSILON,y)-Fn(x-EPSILON,y))/EPSILON }
> #declare Fn1Y = function(x,y)
> { (Fn(x,y+EPSILON)-Fn(x,y-EPSILON))/EPSILON }
>
> // Approximate second derivatives along the x and y axes
> #declare Fn2X = function(x,y)
> { (Fn1X(x+EPSILON,y)-Fn1X(x-EPSILON,y))/EPSILON }
> #declare Fn2Y = function(x,y)
> { (Fn1Y(x,y+EPSILON)-Fn1Y(x,y-EPSILON))/EPSILON }
>
There's a missing (2*..) in all formulas. It should be:
#declare Fn1X = function(x,y)
{ (Fn(x+EPSILON,y)-Fn(x-EPSILON,y))/(2*EPSILON) }
and the same for the others. OTOH if all you want is to know whether it
is positive or negative then you can drop the whole "/EPSILON".
Jerome
--
mailto:jeb### [at] freefr
http://jeberger.free.fr
Jabber: jeb### [at] jabberfr
Post a reply to this message
Attachments:
Download 'us-ascii' (1 KB)
|
|