POV-Ray : Newsgroups : povray.advanced-users : user-defined functions-- basic question of use Server Time
29 Mar 2024 07:13:03 EDT (-0400)
  user-defined functions-- basic question of use (Message 7 to 16 of 16)  
<<< Previous 6 Messages Goto Initial 10 Messages
From: Ive
Subject: Re: user-defined functions-- basic question of use
Date: 26 Feb 2018 04:20:01
Message: <5a93d141@news.povray.org>
Am 2/26/2018 um 1:21 schrieb Kenneth:
> In your opinion (and Bald Eagle's), is the documentation as-is clear enough to
> suggest this proper use? I feel like there is some 'explanatory key to
> understanding' that is missing there.


Well, it seems clear enough to me, but - having not looked at the docs 
myself since decades - I'm the wrong person to ask and my opinion in 
this case doesn't matter.
And I know that I suck when it comes down to explaining anything to 
somebody else...

-Ive


Post a reply to this message

From: Bald Eagle
Subject: Re: user-defined functions-- basic question of use
Date: 26 Feb 2018 09:35:01
Message: <web.5a941a28e9ce4cfdc437ac910@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

> In your opinion (and Bald Eagle's), is the documentation as-is clear enough to
> suggest this proper use? I feel like there is some 'explanatory key to
> understanding' that is missing there.

It's something that I've tried to point out before, in several areas, on several
topics.

A line or two of working code can save 1000 lines of "documentation" and another
week of newsgroup posts trying to figure out the syntax and application.

The documentation isn't too bad _if you already know what you're doing_ , but if
you're a new user trying to do something like this for the first time - it
really almost isn't helpful at all.

Throw a working scene in the distro, or have a few small "blurbs" that DO
something.
The optional macro parameters where "an argument can be omitted" - but you still
need to add in the comma for it, is a good example where it's very hard to
understand that from what's written in the docs.


Post a reply to this message

From: clipka
Subject: Re: user-defined functions-- basic question of use
Date: 26 Feb 2018 11:10:30
Message: <5a943176@news.povray.org>
Am 25.02.2018 um 20:18 schrieb Kenneth:
> I'm familiar with using PIGMENT/PATTERN functions, although it has been awhile.
> But I was looking at 3.3.1.8.4 "Declaring User-Defined Vector Functions" in the
> docs, and it's not clear to me how to actually *use* the examples given there.
> 
> The first example (a transform function) is described only like this:
> 
> #declare foo = function {
>   transform {
>     rotate <90, 0, 0>
>     scale 4
>     }
>   }
> 
> #declare myvector = foo(4, 3, 7);
> 
> How is "myvector" supposed to be used? My assumption is that it 'acts like' a
> transform-- just like any transform{..}-- but I can't get it to work. Maybe I'm
> using it in a totally wrong way?

You're using it totally wrong indeed: While the function does /apply/ a
transform to the parameters submitted, it /acts/ like a vector when
invoked (namely the vector you'd get if you applied the transform to the
vector corresponding to the three parameter values supplied).

E.g,

   #declare T = transform { rotate <90,0,0> scale 4 }
   #declare foo = function { transform { T } }
   #declare myvector = foo(4,3,7);
   sphere { myvector, .3 }

or

   #declare T = transform { rotate <90,0,0> scale 4 }
   #declare foo = function { transform { T } }
   sphere { foo(4,3,7), .3 }

is equivalent to

   #declare T = transform { rotate <90,0,0> scale 4 }
   sphere { vtransform(<4,3,7>,T), .3 }


If you want something that acts like a transform, you must use a
transform. For example:

   #declare T = transform { rotate <90,0,0> scale 4 }
   sphere { 0, .3
      transform { T }
   }


Post a reply to this message

From: Kenneth
Subject: Re: user-defined functions-- basic question of use
Date: 26 Feb 2018 14:35:01
Message: <web.5a945ffce9ce4cfda47873e10@news.povray.org>
In testing this, I see something worth noting.

First, I'll create what looks like a good analog of the doc's function example
(the way that example's operation might appear to a typical or new-user), but
without any function:

sphere{0,0.3 translate <4,3,7>
       transform{
            rotate <90,0,0>
            scale 4
                }
}

And here's Ive's 2nd function-use example (although his 1st works
identically)...
 sphere {foo(4, 3, 7), 0.3}

Both of these put the sphere at exactly the same transformed vector location--
but the non-function example scales the size of the sphere by 4, whereas the
function does not.

Of course, I see the obvious reason why the scales are different in these two
constructs-- but the doc's function example would not be clear at all as to the
difference (IMO) without a useful example to demonstrate it. It would depend on
how familiar users are with functions themselves, and what they do. (Would a new
user attempt to create a function at all, lacking any POV-Ray experience? Maybe,
maybe not.)

In fact, the 'SCALE 4' in the doc's transform was one of the nagging little
questions I was wondering about when I originally posted: in what way the
function affected both the new vector AND the sphere size. Of course, I didn't
know how to use it then. ;-)

The documentation can be a funny thing sometimes: The more obvious
features have good explanations and examples, whereas the more abstruse sections
are lacking-- when THEY need it most.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: user-defined functions-- basic question of use
Date: 26 Feb 2018 16:20:00
Message: <web.5a9479a2e9ce4cfdd21bad850@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> In fact, the 'SCALE 4' in the doc's transform was one of the nagging little
> questions I was wondering about when I originally posted: in what way the
> function affected both the new vector AND the sphere size. Of course, I didn't
> know how to use it then. ;-)
>
> The documentation can be a funny thing sometimes: The more obvious
> features have good explanations and examples, whereas the more abstruse sections
> are lacking-- when THEY need it most.

Well, the documentation was actually written as a book, not as a set of bits to
take and use without the context of the containing sections. The example you
cited is from the section "Declaring User-Defined Vector Functions". A vector
isn't a transformation, because a transormation is actually a matrix ;-)

This gets clearer if you actually read beyond the first bit of the example, down
to the second bit, which includes a spline vector function. There the
documentation explains "Function splines take the vector size into account. That
is, a function containing a spline with five components will also return a five
component vector (aka a color), a function containing a spline with two
components will only return a two component vector and so on."

Of course, having to infer that a tranform function returns a 3D vector isn't
all that trivial indeed. Probably instead of "Function splines take..." it
should read "Function transforms return a three component vector. Function
splines take..."

Thorsten


Post a reply to this message

From: Kenneth
Subject: Re: user-defined functions-- basic question of use
Date: 26 Feb 2018 17:30:00
Message: <web.5a94891be9ce4cfda47873e10@news.povray.org>
"Thorsten Froehlich" <nomail@nomail> wrote:

> Well, the documentation was actually written as a book, not as a set of bits to
> take and use without the context of the containing sections.

Interesting; I didn't know that. And I see your point; that's why I LOVE books,
rather than reading lengthy stuff on the 'net. I can instantly flip back to
something I read previously, all in context.
>
> Of course, having to infer that a tranform function returns a 3D vector isn't
> all that trivial indeed. Probably instead of "Function splines take..." it
> should read "Function transforms return a three component vector. Function
> splines take..."
>

Yes, that sounds MUCH better!


Post a reply to this message

From: Kenneth
Subject: Re: user-defined functions-- basic question of use
Date: 27 Feb 2018 19:10:00
Message: <web.5a95f296e9ce4cfda47873e10@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> "Thorsten Froehlich" <nomail@nomail> wrote:
>
> > Well, the documentation was actually written as a book, not as a set of bits to
> > take and use without the context of the containing sections.
>

Thinking about this further, I suppose that there could have been a different
'philosophy' at work regarding POV-Ray's documentation itself, back when some of
the original docs were written long ago: that the program was meant for those
users who already had programming experience (and the consequent necessary math
skills to go with it.) Meaning, functions et al would have already been
understood as to their uses. Personally, I didn't come from such a programming
background (other than maths classes at university plus some old(!) FORTRAN
experience there, then some BASIC experience as just a hobby.) I guess that's
why I've always wanted the POV-Ray docs to clearly spell out what its
features do, with examples. Especially the harder-to-grasp math parts.

Although, it's a different world now; even kiddies are learning to program!
There are probably 10-year-olds who could teach me more about functions, vector
transforms etc than I already know. ;-)


Post a reply to this message

From: Jim Holsenback
Subject: Re: user-defined functions-- basic question of use
Date: 28 Feb 2018 06:02:42
Message: <5a968c52$1@news.povray.org>
On 02/26/2018 05:24 PM, Kenneth wrote:
> "Thorsten Froehlich" <nomail@nomail> wrote:
> 
>> Well, the documentation was actually written as a book, not as a set of bits to
>> take and use without the context of the containing sections.
> 
> Interesting; I didn't know that. And I see your point; that's why I LOVE books,
> rather than reading lengthy stuff on the 'net. I can instantly flip back to
> something I read previously, all in context.
>>
>> Of course, having to infer that a tranform function returns a 3D vector isn't
>> all that trivial indeed. Probably instead of "Function splines take..." it
>> should read "Function transforms return a three component vector. Function
>> splines take..."
>>
> 
> Yes, that sounds MUCH better!

agreed...http://wiki.povray.org/content/Reference:Function#Declaring_User-Defined_Vector_Functions


Post a reply to this message

From: Jim Holsenback
Subject: Re: user-defined functions-- basic question of use
Date: 28 Feb 2018 06:03:32
Message: <5a968c84$1@news.povray.org>
On 02/28/2018 06:02 AM, Jim Holsenback wrote:
> On 02/26/2018 05:24 PM, Kenneth wrote:
>> "Thorsten Froehlich" <nomail@nomail> wrote:
>>
>>> Well, the documentation was actually written as a book, not as a set 
>>> of bits to
>>> take and use without the context of the containing sections.
>>
>> Interesting; I didn't know that. And I see your point; that's why I 
>> LOVE books,
>> rather than reading lengthy stuff on the 'net. I can instantly flip 
>> back to
>> something I read previously, all in context.
>>>
>>> Of course, having to infer that a tranform function returns a 3D 
>>> vector isn't
>>> all that trivial indeed. Probably instead of "Function splines 
>>> take..." it
>>> should read "Function transforms return a three component vector. 
>>> Function
>>> splines take..."
>>>
>>
>> Yes, that sounds MUCH better!
> 
>
agreed...http://wiki.povray.org/content/Reference:Function#Declaring_User-Defined_Vector_Functions

> 
> 
oops forget a space 
http://wiki.povray.org/content/Reference:Function#Declaring_User-Defined_Vector_Functions


Post a reply to this message

From: Kenneth
Subject: Re: user-defined functions-- basic question of use
Date: 28 Feb 2018 07:35:00
Message: <web.5a96a17ae9ce4cfda47873e10@news.povray.org>
Jim Holsenback <ash### [at] nospamcom> wrote:

> >
> > agreed...
> oops forget a space
>
http://wiki.povray.org/content/Reference:Function#Declaring_User-Defined_Vector_Functions

Uh, any chance of including I've's little examples, for at least the transform
part?  :-) :-)  They would be SO helpful to poor schleps like me, ha.

sphere {myvector, 0.3
      pigment {rgb <0,1,0>}
}

or

sphere {foo(4, 3, 7), 0.3
      pigment {rgb <0,1,0>}
}


Post a reply to this message

<<< Previous 6 Messages Goto Initial 10 Messages

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