POV-Ray : Newsgroups : povray.advanced-users : Is there a way Server Time
26 Nov 2024 09:21:27 EST (-0500)
  Is there a way (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Mick Hazelgrove
Subject: Is there a way
Date: 17 Sep 2000 14:40:04
Message: <39c51004@news.povray.org>
Is there a way of  doing

    x (+ or -) y ?

Mick


Post a reply to this message

From: Margus Ramst
Subject: Re: Is there a way
Date: 17 Sep 2000 15:17:57
Message: <39C50ABB.A59A52A0@peak.edu.ee>
Mick Hazelgrove wrote:
> 
> Is there a way of  doing
> 
>     x (+ or -) y ?
> 

Could you be a bit more specific as to what scenario you have in mind?
Conditionals? Isosurfaces? Loop counters? ...?

-- 
Margus Ramst

Personal e-mail: mar### [at] peakeduee
TAG (Team Assistance Group) e-mail: mar### [at] tagpovrayorg


Post a reply to this message

From: Mick Hazelgrove
Subject: Re: Is there a way
Date: 17 Sep 2000 16:56:56
Message: <39c53018@news.povray.org>
I want to translate an object. I often come across the situation where I
want to randomly add a increment to a translation either side of zero. ie
translate x* (+or - increment) usually in a loop.

I've used mod to alternate either side of zero but I'd like it to be random.

Hope that makes sense

Mick

"Margus Ramst" <mar### [at] peakeduee> wrote in message
news:39C50ABB.A59A52A0@peak.edu.ee...
> Mick Hazelgrove wrote:
> >
> > Is there a way of  doing
> >
> >     x (+ or -) y ?
> >
>
> Could you be a bit more specific as to what scenario you have in mind?
> Conditionals? Isosurfaces? Loop counters? ...?
>
> --
> Margus Ramst
>
> Personal e-mail: mar### [at] peakeduee
> TAG (Team Assistance Group) e-mail: mar### [at] tagpovrayorg


Post a reply to this message

From: Rich
Subject: Re: Is there a way
Date: 17 Sep 2000 17:05:44
Message: <8FB299004spammindspringcom@204.213.191.228>
mic### [at] mhazelgrovefsnetcouk (Mick Hazelgrove) wrote in
<39c53018@news.povray.org>: 
>> > Is there a way of  doing
>> >
>> >     x (+ or -) y ?

   How about (x - y) + random number between 0 and y*2
or
   x + ((random number between 0 and y*2) - y)

-- 
Rich Allen
(Remove SPAM from my address to reply by e-mail)


Post a reply to this message

From: Margus Ramst
Subject: Re: Is there a way
Date: 17 Sep 2000 18:43:17
Message: <39C53ADB.23ADAC7B@peak.edu.ee>
Mick Hazelgrove wrote:
> 
> I want to translate an object. I often come across the situation where I
> want to randomly add a increment to a translation either side of zero. ie
> translate x* (+or - increment) usually in a loop.
> 

I'm still a bit unclear, but perhaps this macro will do the job:

//Seed - declared random number seed
#macro PlusMinus(Seed)
    #local U=rand(Seed);
    #if(U<.5) (-1) #else 1 #end
#end

This returns -1 or 1 at random, so basically: x*PlusMinus(Seed)*y shall
alternate between incrementing and decrementing.

-- 
Margus Ramst

Personal e-mail: mar### [at] peakeduee
TAG (Team Assistance Group) e-mail: mar### [at] tagpovrayorg


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Is there a way
Date: 17 Sep 2000 19:20:55
Message: <39C5507E.4941A62E@hotmail.com>
Mick Hazelgrove wrote:
> 
> I want to translate an object. I often come across the situation where I
> want to randomly add a increment to a translation either side of zero. ie
> translate x* (+or - increment) usually in a loop.
> 
> I've used mod to alternate either side of zero but I'd like it to be random.

There are many solutions to this problem.
Below you can find two of my suggestions.


If you have prepared your randomization seed 
e.g. like this:

#declare RR = seed(314);


Then to get what you wrote in the first post;

x (+ or -) y

you could write:


x + (2*int(rand(RR) + 0.5) - 1)*y

or 

x + (rand(RR) > 0.5 ? 1 : -1)*y



To get what you wrote in your second post;

x* (+or - increment)

you could write:


x*(2*int(rand(RR) + 0.5) - 1)*increment

or

x*(rand(RR) > 0.5 ? 1 : -1)*increment



Tor Olav
--
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html


Post a reply to this message

From: Chris Colefax
Subject: Re: Is there a way
Date: 17 Sep 2000 19:20:56
Message: <39c551d8@news.povray.org>
Mick Hazelgrove <mic### [at] mhazelgrovefsnetcouk> wrote:
> Is there a way of  doing
>
>     x (+ or -) y ?

This is something I use a lot in my work - code like this should do the
trick:

   BaseAmount + (rand(Seed) - 0.5) * Randomness

For example, if you wanted to scale objects within 2 unit of 10 units, use
(10 + (rand(R1)-.5)*2).


Post a reply to this message

From: Warp
Subject: Posting to the right group (Was: Is there a way)
Date: 18 Sep 2000 05:23:46
Message: <39c5df22@news.povray.org>
I wouldn't want to fall into elitism nor want people thinking that I'm
arrogant or anything.
  However, I would like people to think whether a question belongs to
povray.newusers or to povray.advanced-users before posting.
  Of course it doesn't make much harm if a question goes to the wrong group
sometimes, but still it would be nicer if the articles were in their
respective groups.

  Of course here comes the elitism: What kind of questions can be posted
to p.a-u what cannot?
  Well, this is a free place and anyone can ask whatever they wish wherever
they want, and I'm not the one who decides whether a post is in the wrong
place or not. I'm not a server moderator or anything similar, and I don't
want to be one (although some may think otherwise...). I'm just a regular
user, as anyone else. I'm just expressing my opinion.
  Well, my personal opinion is that an extremely basic math question such
as "how do I get numbers from x-y to x+y?" is more suitable to the
povray.newusers group.
  A math question that belongs to p.a-u could be, for example, "how do I
make a fourier transform with povray code?".
  Others may have a differing point of view, and they are welcome.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Pete
Subject: Re: Is there a way
Date: 20 Sep 2000 20:33:27
Message: <217.298T2910T12026459PeterC@nym.alias.net>
Mick wrote:

>Is there a way of  doing

>    x (+ or -) y ?

>Mick


  D'ya mean like ...

  #declare randomness = 0.5;  // plus or minus up to this amount
  #declare xx = (0.5 - rand(rseed)) * randomness;

  ?

Pete


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Posting to the right group (Was: Is there a way)
Date: 21 Sep 2000 11:37:12
Message: <39CA29EA.4F7F9BE7@my-dejanews.com>
Warp wrote:

>   I wouldn't want to fall into elitism nor want people thinking that I'm
> arrogant or anything.
> ...

> Well, my personal opinion is that an extremely basic math question such as
> "how do I get numbers from x-y to x+y?" is more suitable to the
> povray.newusers group.   A math question that belongs to p.a-u could be, for
> example, "how do I make a fourier transform with povray code?".   Others may
> have a differing point of view, and they are welcome.

I guess it all depends on one's perception of a trivially easy question.


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

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