|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Tttttsssssssssssssssssssssssss.
That is insider knowledge! Thanks! I would never have discovered this
option on my own. Giving a try. :-)
---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 04/05/2018 12:21 PM, clipka wrote:
> #declare MySeed = seed(4711);
> #macro MyRand(Min,Max)
> // compute stuff
> #local Rand = rand(MySeed);
> #local Result = Min + (Max-Min)*Rand;
> // "return" the computed value
> Result
> #end
>
I wrap the return value in parenthesis. The intent is a little clearer
in the macro def and may avoid usage problems.
// "return" the computed value
(Result)
I know clipka, legally this is not required, because Result is a single
number. But I tend to do
#local V=<1,2,3>;
// "return" the computed value
(Result+V)
where it is morally (debuggingly?) required.
sven, this is because when you use it, think of the expansion.
#local R = MyRand(low, high) * 2;
which without parens, is
#local R = Result + V * 2
which of course evaluates as
#local R = Result + (V * 2)
which is not at all what you want. With the parens, you get
#local R = (Result + V) * 2
which is the intent of your usage.
--
dik
Rendered 328976 of 330000 (99%)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 5-4-2018 22:57, Bald Eagle wrote:
> And you don't even really need a separate function or macro - just use
>
> #include "rand.inc"
>
> then use (IIRC)
>
> RRand (0, 360)
>
> or
>
> RRand (-180, 180) to give you your rotation angles directly.
>
To be correct:
#declare R=seed(1234);
RRand (-180, 180, R)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 6-4-2018 0:41, Sven Littkowski wrote:
> Tttttsssssssssssssssssssssssss.
>
> That is insider knowledge! Thanks! I would never have discovered this
> option on my own. Giving a try. :-)
>
Everybody can discover it. No "insider knowledge" here at all imo. When
you need randomness, you naturally go and look at the content of
rand.inc and its description in the docs. Nothing arcane involved.
--
Thomas
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Using RRand now, testing. Looks good.
---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I just did not know about the existence of that include. But such is
life: you never stop to discover or learn new things. :-)
---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Yes, I already found it that. I opened that include file, and saw the
parameter for the SEED item.
---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 06.04.2018 um 03:02 schrieb dick balaska:
> On 04/05/2018 12:21 PM, clipka wrote:
>
>> #declare MySeed = seed(4711);
>> #macro MyRand(Min,Max)
>> // compute stuff
>> #local Rand = rand(MySeed);
>> #local Result = Min + (Max-Min)*Rand;
>> // "return" the computed value
>> Result
>> #end
>>
>
> I wrap the return value in parenthesis. The intent is a little clearer
> in the macro def and may avoid usage problems.
>
> // "return" the computed value
> (Result)
You run into problems with this approach if you ever want to return
something that isn't a scalar or vector. For instance, the following
won't fly:
#macro FullName(FileName)
#local Result = concat("C:/Fnord/", FileName);
(Result)
#end
#include FullName("stuff.inc")
> I know clipka, legally this is not required, because Result is a single
> number. But I tend to do
>
> #local V=<1,2,3>;
> // "return" the computed value
> (Result+V)
>
> where it is morally (debuggingly?) required.
Then maybe don't do that ;)
I really literally use `Result` as the local variable name, and make
sure to always store the very end result in there, for the same purpose
that you use the parentheses. That way
Result
is guaranteed to be the only thing the macro "emits". Solves the same
problem as your parentheses, but has the added benefit of working in
more scenarios.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 6-4-2018 13:16, Sven Littkowski wrote:
> I just did not know about the existence of that include. But such is
> life: you never stop to discover or learn new things. :-)
>
I cannot believe this! :-O
I would urgently ask you to look at the POV-Ray folders! You pretend you
have been using POV-Ray for over /ten/ years and you /never ever/ looked
into the include?!? the Insert Menu?!? the scenes?!? folders; not to
speak of the documentation. I begin to understand the background of some
of your questions...
--
Thomas
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Well, of course I have looked at files inside the INCLUDE folder many,
many times, but each time I checked only on some specific names, mostly
when i ran into some problems. Can't change it.
I actually use POV-Ray since 1990 or so... :-D
---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |