Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

panic: kernel trap (ignored)


devel / comp.lang.c / Re: random points near central point

SubjectAuthor
* random points near central pointfir
+* Re: random points near central pointMalcolm McLean
|`- Re: random points near central pointfir
+- Re: random points near central pointMalcolm McLean
+- Re: random points near central pointKaz Kylheku
+* Re: random points near central pointBen Bacarisse
|`* Re: random points near central pointfir
| +* Re: random points near central pointBen Bacarisse
| |+* Re: random points near central pointfir
| ||+- Re: random points near central pointBen Bacarisse
| ||`* Re: random points near central pointDavid Brown
| || `* Re: random points near central pointfir
| ||  `* Re: random points near central pointEd Prochak
| ||   `* Re: random points near central pointfir
| ||    +* Re: random points near central pointBen Bacarisse
| ||    |`* Re: random points near central pointfir
| ||    | `- Re: random points near central pointChris M. Thomasson
| ||    `* Re: random points near central pointEd Prochak
| ||     `- Re: random points near central pointfir
| |`- Re: random points near central pointfir
| `* Re: random points near central pointChris M. Thomasson
|  `* Re: random points near central pointfir
|   `- Re: random points near central pointChris M. Thomasson
+- Re: random points near central pointChris M. Thomasson
+* Re: random points near central pointBonita Montero
|`* Re: random points near central pointfir
| +- Re: random points near central pointfir
| `* Re: random points near central pointBonita Montero
|  `- Re: random points near central pointfir
+* Re: random points near central pointJohn Forkosh
|`* Re: random points near central pointfir
| `* Re: random points near central pointJohn Forkosh
|  `* Re: random points near central pointfir
|   `- Re: random points near central pointfir
`- Re: random points near central pointChris M. Thomasson

Pages:12
Re: random points near central point

<8412502b-87b6-4ce2-933b-f2b8eea2b181n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26972&group=comp.lang.c#26972

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:bd41:0:b0:76c:b8ab:7918 with SMTP id n62-20020a37bd41000000b0076cb8ab7918mr60440qkf.8.1691085335845;
Thu, 03 Aug 2023 10:55:35 -0700 (PDT)
X-Received: by 2002:a05:6808:2101:b0:3a6:fea7:5889 with SMTP id
r1-20020a056808210100b003a6fea75889mr28825160oiw.11.1691085335695; Thu, 03
Aug 2023 10:55:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 3 Aug 2023 10:55:35 -0700 (PDT)
In-Reply-To: <uagne8$rfjo$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.139; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.139
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com> <uagne8$rfjo$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8412502b-87b6-4ce2-933b-f2b8eea2b181n@googlegroups.com>
Subject: Re: random points near central point
From: profesor...@gmail.com (fir)
Injection-Date: Thu, 03 Aug 2023 17:55:35 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3459
 by: fir - Thu, 3 Aug 2023 17:55 UTC

czwartek, 3 sierpnia 2023 o 19:17:11 UTC+2 Bonita Montero napisał(a):
> Am 19.07.2023 um 08:38 schrieb fir:
> > i need tos et asteroids in game (about 100 or 200) but not in square
> > area with two rands one for x and second for y but need it to
> > be sphericel symetric around central point and in more densitu near it and less desity with bigger radius until some radius when it is zero
> >
> > something like
> >
> > SetRandomPointSphericalSymetricAndFadingWithDistance(
> > float x, float y, float r1, float r2);
> >
> > this r1 is radius of circle below which density is max and r2 is radius
> > where above density is zero - in beetweem r1 and r2 density should
> > be from max (at r1) to zero at r2
> >
> > how to do that?
> In C++ I'd do that this way:
>
> #include <random>
> #include <cmath>
>
> using namespace std;
>
> double nearDistance( double d )
> {
> thread_local double exp = 2.0;
> thread_local mt19937_64 mt;
> thread_local uniform_real_distribution<double> rnd1( 0.0, 1.0 );
> if( d < 0.0 ) [[unlikely]]
> {
> double beforeExp = exp;
> exp = -d;
> return beforeExp;
> }
> return pow( rnd1( mt ), exp ) * d;
> }
>
> This gives values from 0.0 to d which are more likely to be near
> to 0.0 than with a linear exponent. The exponent can be changed
> and should be > 1.0.

dont know what it is, howewer thinkong of what i wrote
if
x = rand2(0,a); gives 'rectangle' density

//rand2(a,b) gives random from a to b)

then there i should probably transform helf of the points (as rectangle is two triangles) into triangle
but how? should i maybe take x/a which is from 0 to 1 and take it as a probablility of 'flipping'
the value from right-up triangl;e to left-down?
int GiveRandomVauleWithLinearlyDecayingDensity(int A, int B)
{ x = rand2(A,B);
float flip_probability = 1.*(x-A)/(B-A);
if(chance(flip_probability)) x = A + (B - x);
}

this just flips the x values from more right area of A to B span based on how right vaule this is

chance would be a function returning tru with a chance of flip_probability

dont know but maybe this is what i need

Re: random points near central point

<4d51816d-ed7a-4969-84e0-c0c23037e79fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26974&group=comp.lang.c#26974

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:190a:b0:40f:d6f0:7681 with SMTP id w10-20020a05622a190a00b0040fd6f07681mr61242qtc.3.1691085881153;
Thu, 03 Aug 2023 11:04:41 -0700 (PDT)
X-Received: by 2002:a05:6808:16ab:b0:39c:f0c2:e3ad with SMTP id
bb43-20020a05680816ab00b0039cf0c2e3admr30664692oib.5.1691085880840; Thu, 03
Aug 2023 11:04:40 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 3 Aug 2023 11:04:40 -0700 (PDT)
In-Reply-To: <8412502b-87b6-4ce2-933b-f2b8eea2b181n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.139; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.139
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<uagne8$rfjo$1@dont-email.me> <8412502b-87b6-4ce2-933b-f2b8eea2b181n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4d51816d-ed7a-4969-84e0-c0c23037e79fn@googlegroups.com>
Subject: Re: random points near central point
From: profesor...@gmail.com (fir)
Injection-Date: Thu, 03 Aug 2023 18:04:41 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3922
 by: fir - Thu, 3 Aug 2023 18:04 UTC

czwartek, 3 sierpnia 2023 o 19:55:44 UTC+2 fir napisał(a):
> czwartek, 3 sierpnia 2023 o 19:17:11 UTC+2 Bonita Montero napisał(a):
> > Am 19.07.2023 um 08:38 schrieb fir:
> > > i need tos et asteroids in game (about 100 or 200) but not in square
> > > area with two rands one for x and second for y but need it to
> > > be sphericel symetric around central point and in more densitu near it and less desity with bigger radius until some radius when it is zero
> > >
> > > something like
> > >
> > > SetRandomPointSphericalSymetricAndFadingWithDistance(
> > > float x, float y, float r1, float r2);
> > >
> > > this r1 is radius of circle below which density is max and r2 is radius
> > > where above density is zero - in beetweem r1 and r2 density should
> > > be from max (at r1) to zero at r2
> > >
> > > how to do that?
> > In C++ I'd do that this way:
> >
> > #include <random>
> > #include <cmath>
> >
> > using namespace std;
> >
> > double nearDistance( double d )
> > {
> > thread_local double exp = 2.0;
> > thread_local mt19937_64 mt;
> > thread_local uniform_real_distribution<double> rnd1( 0.0, 1.0 );
> > if( d < 0.0 ) [[unlikely]]
> > {
> > double beforeExp = exp;
> > exp = -d;
> > return beforeExp;
> > }
> > return pow( rnd1( mt ), exp ) * d;
> > }
> >
> > This gives values from 0.0 to d which are more likely to be near
> > to 0.0 than with a linear exponent. The exponent can be changed
> > and should be > 1.0.
> dont know what it is, howewer thinkong of what i wrote
> if
> x = rand2(0,a); gives 'rectangle' density
>
> //rand2(a,b) gives random from a to b)
>
> then there i should probably transform helf of the points (as rectangle is two triangles) into triangle
> but how? should i maybe take x/a which is from 0 to 1 and take it as a probablility of 'flipping'
> the value from right-up triangl;e to left-down?
>
> int GiveRandomVauleWithLinearlyDecayingDensity(int A, int B)
> {
> x = rand2(A,B);
> float flip_probability = 1.*(x-A)/(B-A);
> if(chance(flip_probability)) x = A + (B - x);
> }
>
> this just flips the x values from more right area of A to B span based on how right vaule this is
>
> chance would be a function returning tru with a chance of flip_probability
>
> dont know but maybe this is what i need

btw how thuis chance function code shoule be?

int chance(float p)
{ return p>= float(rand()&0x7fff)/0x7fff;;
}

?

Re: random points near central point

<uaj538$1aocd$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27013&group=comp.lang.c#27013

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: random points near central point
Date: Fri, 4 Aug 2023 17:22:21 +0200
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <uaj538$1aocd$1@dont-email.me>
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<uagne8$rfjo$1@dont-email.me>
<8412502b-87b6-4ce2-933b-f2b8eea2b181n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 4 Aug 2023 15:22:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ce6110ed2775404d03fa52cb6e93461a";
logging-data="1401229"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+f/wkH4C+BSNMEeISfYebRaBwX751/Z+0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:3CaZ3CcOH2xvqcx0Gkf1fNaAxk4=
Content-Language: de-DE
In-Reply-To: <8412502b-87b6-4ce2-933b-f2b8eea2b181n@googlegroups.com>
 by: Bonita Montero - Fri, 4 Aug 2023 15:22 UTC

Am 03.08.2023 um 19:55 schrieb fir:

> dont know what it is, ...

Im taking a random double between 0.0 and 1.0, exponentiate it with
an exponent > 1.0, thereby having more small output values than high
and then I multiply that with the maximum value supplied. This makes
the desired distribution where lower values are more likely as you
increase the exponent.

Re: random points near central point

<cfaf3956-bcd0-4752-9ff2-60f70cbd8cd4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27019&group=comp.lang.c#27019

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:199f:b0:767:dd55:2add with SMTP id bm31-20020a05620a199f00b00767dd552addmr7652qkb.14.1691168768555;
Fri, 04 Aug 2023 10:06:08 -0700 (PDT)
X-Received: by 2002:a05:6870:5a99:b0:1b0:328b:876a with SMTP id
dt25-20020a0568705a9900b001b0328b876amr2385243oab.1.1691168768309; Fri, 04
Aug 2023 10:06:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 4 Aug 2023 10:06:07 -0700 (PDT)
In-Reply-To: <uaj538$1aocd$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.71; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.71
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<uagne8$rfjo$1@dont-email.me> <8412502b-87b6-4ce2-933b-f2b8eea2b181n@googlegroups.com>
<uaj538$1aocd$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cfaf3956-bcd0-4752-9ff2-60f70cbd8cd4n@googlegroups.com>
Subject: Re: random points near central point
From: profesor...@gmail.com (fir)
Injection-Date: Fri, 04 Aug 2023 17:06:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2148
 by: fir - Fri, 4 Aug 2023 17:06 UTC

piątek, 4 sierpnia 2023 o 17:22:30 UTC+2 Bonita Montero napisał(a):
> Am 03.08.2023 um 19:55 schrieb fir:
>
> > dont know what it is, ...
>
> Im taking a random double between 0.0 and 1.0, exponentiate it with
> an exponent > 1.0, thereby having more small output values than high
> and then I multiply that with the maximum value supplied. This makes
> the desired distribution where lower values are more likely as you
> increase the exponent.

probably should work but i wrote this laternative with fliping...

on the right side the probablility of flipping to left (like 0.8 to 0.2, or 0.9 to 0.1) is
rising to 100% where on left it is rising form 0% so this probably could turn "rectangle" distribution into triangle... but i dont need this code for hurry so now im not plan to test it - will test it when i will need it

Re: random points near central point

<ual9ur$t6d$1@reader2.panix.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27068&group=comp.lang.c#27068

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.2001:470:30::a654:103!not-for-mail
From: fork...@panix.com (John Forkosh)
Newsgroups: comp.lang.c
Subject: Re: random points near central point
Date: Sat, 5 Aug 2023 10:57:32 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <ual9ur$t6d$1@reader2.panix.com>
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
Injection-Date: Sat, 5 Aug 2023 10:57:32 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="2001:470:30::a654:103";
logging-data="29901"; mail-complaints-to="abuse@panix.com"
User-Agent: tin/2.6.0-20210823 ("Coleburn") (NetBSD/9.3 (amd64))
 by: John Forkosh - Sat, 5 Aug 2023 10:57 UTC

fir <profesor.fir@gmail.com> wrote:
> i need to set asteroids in game (about 100 or 200) but not in square
> area with two rands one for x and second for y but need it to
> be sphericel symetric around central point and in more density near it
> and less desity with bigger radius until some radius when it is zero
>
> something like
>
> SetRandomPointSphericalSymetricAndFadingWithDistance(
> float x, float y, float r1, float r2);
>
> this r1 is radius of circle below which density is max and r2 is radius
> where above density is zero - in beetweem r1 and r2 density should
> be from max (at r1) to zero at r2
>
> how to do that?

Haven't read the followups. You mean something like...
https://www.deviantart.com/eigenheit22/art/Starfield-v1-860092004
....without the animation? That's done in x,y (and z). And you can then
just calculate r=sqrt(x*x+y*y) and discard the ones you don't like.
--
John Forkosh ( mailto: j@f.com where j=john and f=forkosh )

Re: random points near central point

<89aaec9e-04e9-4b20-8bdc-7e0db8fca358n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27077&group=comp.lang.c#27077

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:6a85:b0:76c:daf4:2787 with SMTP id ud5-20020a05620a6a8500b0076cdaf42787mr11516qkn.4.1691239287431;
Sat, 05 Aug 2023 05:41:27 -0700 (PDT)
X-Received: by 2002:a9d:66c8:0:b0:6b2:a87b:e441 with SMTP id
t8-20020a9d66c8000000b006b2a87be441mr4629563otm.3.1691239287113; Sat, 05 Aug
2023 05:41:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sat, 5 Aug 2023 05:41:26 -0700 (PDT)
In-Reply-To: <ual9ur$t6d$1@reader2.panix.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.157; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.157
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com> <ual9ur$t6d$1@reader2.panix.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <89aaec9e-04e9-4b20-8bdc-7e0db8fca358n@googlegroups.com>
Subject: Re: random points near central point
From: profesor...@gmail.com (fir)
Injection-Date: Sat, 05 Aug 2023 12:41:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2556
 by: fir - Sat, 5 Aug 2023 12:41 UTC

sobota, 5 sierpnia 2023 o 12:57:46 UTC+2 John Forkosh napisał(a):
> fir <profes...@gmail.com> wrote:
> > i need to set asteroids in game (about 100 or 200) but not in square
> > area with two rands one for x and second for y but need it to
> > be sphericel symetric around central point and in more density near it
> > and less desity with bigger radius until some radius when it is zero
> >
> > something like
> >
> > SetRandomPointSphericalSymetricAndFadingWithDistance(
> > float x, float y, float r1, float r2);
> >
> > this r1 is radius of circle below which density is max and r2 is radius
> > where above density is zero - in beetweem r1 and r2 density should
> > be from max (at r1) to zero at r2
> >
> > how to do that?
> Haven't read the followups. You mean something like...
> https://www.deviantart.com/eigenheit22/art/Starfield-v1-860092004
> ...without the animation? That's done in x,y (and z). And you can then
> just calculate r=sqrt(x*x+y*y) and discard the ones you don't like.

possibly - now i think you just can imagine field of discarding (from 0.0 to 1.0 chance of discarding in given point) then just calculate chnce of discarding in that point according to a field and use it

thsi is a bit wastefull to count something than discard it but probably could be enough ok

Re: random points near central point

<uaoqf4$2ea19$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27134&group=comp.lang.c#27134

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: random points near central point
Date: Sun, 6 Aug 2023 11:57:40 -0700
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <uaoqf4$2ea19$2@dont-email.me>
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 6 Aug 2023 18:57:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="73dd435a6f6fd0066b15fc1315426cc8";
logging-data="2566185"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Bpy+q0j4UnXWkti5GY4vOSt3b/SfdtRY="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:dszTCBX9tzL6UbFTzSJeeqPZ1SQ=
Content-Language: en-US
In-Reply-To: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
 by: Chris M. Thomasson - Sun, 6 Aug 2023 18:57 UTC

On 7/18/2023 11:38 PM, fir wrote:
> i need tos et asteroids in game (about 100 or 200) but not in square
> area with two rands one for x and second for y but need it to
> be sphericel symetric around central point and in more densitu near it and less desity with bigger radius until some radius when it is zero
>
> something like
>
> SetRandomPointSphericalSymetricAndFadingWithDistance(
> float x, float y, float r1, float r2);
>
> this r1 is radius of circle below which density is max and r2 is radius
> where above density is zero - in beetweem r1 and r2 density should
> be from max (at r1) to zero at r2
>
> how to do that?

Fwiw, check out this older simulation I made around 9 years ago:

https://youtu.be/-EaHLaZbMFs

It tries to diffuse itself...

Re: random points near central point

<uaqqi0$ijf$1@reader2.panix.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27158&group=comp.lang.c#27158

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.2001:470:30::a654:103!not-for-mail
From: fork...@panix.com (John Forkosh)
Newsgroups: comp.lang.c
Subject: Re: random points near central point
Date: Mon, 7 Aug 2023 13:11:28 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <uaqqi0$ijf$1@reader2.panix.com>
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com> <ual9ur$t6d$1@reader2.panix.com> <89aaec9e-04e9-4b20-8bdc-7e0db8fca358n@googlegroups.com>
Injection-Date: Mon, 7 Aug 2023 13:11:28 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="2001:470:30::a654:103";
logging-data="19055"; mail-complaints-to="abuse@panix.com"
User-Agent: tin/2.6.0-20210823 ("Coleburn") (NetBSD/9.3 (amd64))
 by: John Forkosh - Mon, 7 Aug 2023 13:11 UTC

fir <profesor.fir@gmail.com> wrote:
> John Forkosh wrote(a):
>> fir <profes...@gmail.com> wrote:
>> > i need to set asteroids in game (about 100 or 200) but not in square
>> > area with two rands one for x and second for y but need it to
>> > be sphericel symetric around central point and in more density near it
>> > and less desity with bigger radius until some radius when it is zero
>> >
>> > something like
>> > SetRandomPointSphericalSymetricAndFadingWithDistance(
>> > float x, float y, float r1, float r2);
>> > this r1 is radius of circle below which density is max and r2 is radius
>> > where above density is zero - in beetweem r1 and r2 density should
>> > be from max (at r1) to zero at r2
>> > how to do that?
>>
>> Haven't read the followups. You mean something like...
>> https://www.deviantart.com/eigenheit22/art/Starfield-v1-860092004
>> ...without the animation? That's done in x,y (and z). And you can then
>> just calculate r=sqrt(x*x+y*y) and discard the ones you don't like.
>
> possibly - now i think you just can imagine field of discarding
> (from 0.0 to 1.0 chance of discarding in given point) then just
> calculate chnce of discarding in that point according to a field
> and use it
>
> this is a bit wasteful to count something than discard it but
> probably could be enough ok

You said 100-200 asteroids, so "wasteful" is hardly a concern.
But if you're concerned anyway, suppose you wanted asteroids
at radius r1 <= r <= r2 (you wanted "max density" at r<=r1,
whereas this will give 0 at r<r1 and r>r2; your exercise is to
figure out the necessary modification). So go back to r,theta
polar coords and just do something along the following lines...
#include <stdlib.h>
#include <math.h>
void SetRandomPoint( double r1, double r2, double *x, double *y ) {
double r = r1 + (r2-r1)*drand48(), /* random r1<=r<r2 */
theta = 2.0*3.14159*drand48(); /* random 0<=theta<2pi */
*x = r*cos(theta); *y = r*sin(theta); /* return random x,y coords */
return; }
And the density will naturally decrease with increasing r.
No work required.
--
John Forkosh ( mailto: j@f.com where j=john and f=forkosh )

Re: random points near central point

<75bc1057-8934-44af-911e-cacbbec60bc2n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27160&group=comp.lang.c#27160

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:b905:0:b0:76c:b12c:2fe8 with SMTP id j5-20020a37b905000000b0076cb12c2fe8mr29976qkf.13.1691414795643;
Mon, 07 Aug 2023 06:26:35 -0700 (PDT)
X-Received: by 2002:a05:6808:208d:b0:3a7:4a41:1899 with SMTP id
s13-20020a056808208d00b003a74a411899mr16519801oiw.9.1691414795367; Mon, 07
Aug 2023 06:26:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 7 Aug 2023 06:26:34 -0700 (PDT)
In-Reply-To: <uaqqi0$ijf$1@reader2.panix.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.123; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.123
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<ual9ur$t6d$1@reader2.panix.com> <89aaec9e-04e9-4b20-8bdc-7e0db8fca358n@googlegroups.com>
<uaqqi0$ijf$1@reader2.panix.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <75bc1057-8934-44af-911e-cacbbec60bc2n@googlegroups.com>
Subject: Re: random points near central point
From: profesor...@gmail.com (fir)
Injection-Date: Mon, 07 Aug 2023 13:26:35 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4596
 by: fir - Mon, 7 Aug 2023 13:26 UTC

poniedziałek, 7 sierpnia 2023 o 15:13:37 UTC+2 John Forkosh napisał(a):
> fir <profes...@gmail.com> wrote:
> > John Forkosh wrote(a):
> >> fir <profes...@gmail.com> wrote:
> >> > i need to set asteroids in game (about 100 or 200) but not in square
> >> > area with two rands one for x and second for y but need it to
> >> > be sphericel symetric around central point and in more density near it
> >> > and less desity with bigger radius until some radius when it is zero
> >> >
> >> > something like
> >> > SetRandomPointSphericalSymetricAndFadingWithDistance(
> >> > float x, float y, float r1, float r2);
> >> > this r1 is radius of circle below which density is max and r2 is radius
> >> > where above density is zero - in beetweem r1 and r2 density should
> >> > be from max (at r1) to zero at r2
> >> > how to do that?
> >>
> >> Haven't read the followups. You mean something like...
> >> https://www.deviantart.com/eigenheit22/art/Starfield-v1-860092004
> >> ...without the animation? That's done in x,y (and z). And you can then
> >> just calculate r=sqrt(x*x+y*y) and discard the ones you don't like.
> >
> > possibly - now i think you just can imagine field of discarding
> > (from 0.0 to 1.0 chance of discarding in given point) then just
> > calculate chnce of discarding in that point according to a field
> > and use it
> >
> > this is a bit wasteful to count something than discard it but
> > probably could be enough ok
> You said 100-200 asteroids, so "wasteful" is hardly a concern.
> But if you're concerned anyway, suppose you wanted asteroids
> at radius r1 <= r <= r2 (you wanted "max density" at r<=r1,
> whereas this will give 0 at r<r1 and r>r2; your exercise is to
> figure out the necessary modification). So go back to r,theta
> polar coords and just do something along the following lines...
> #include <stdlib.h>
> #include <math.h>
> void SetRandomPoint( double r1, double r2, double *x, double *y ) {
> double r = r1 + (r2-r1)*drand48(), /* random r1<=r<r2 */
> theta = 2.0*3.14159*drand48(); /* random 0<=theta<2pi */
> *x = r*cos(theta); *y = r*sin(theta); /* return random x,y coords */
> return; }
> And the density will naturally decrease with increasing r.
> No work required.

i wanted max constand density say in radius 100 then linerally decaying say
in radius from 300

it seems the rand only givesflat density, then probably proper way fould be to tranmsform/project this square cordinates into other shape as density is proportional to 'surface'if some transforms the surface stretching it or densing by some x,y -> x', y' then it will have les random density

but i dont remember how to do transformations ([probably they are normal functions of x,y into new x,y so some could be found) but there is also thsi way with making fields of percentage of discarding

this function is handy to me but its also not any way critical i need it jsu to set things in agme liak asteroid fields, space flowers or something liek that (but dont hope it would be look god i only write games wth symbolic graphics, something like kinda roguelikes)

Re: random points near central point

<ab2d57c0-80f1-4729-9fe5-253edb910af4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27161&group=comp.lang.c#27161

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:558d:0:b0:63c:f38d:e0ce with SMTP id f13-20020ad4558d000000b0063cf38de0cemr42399qvx.1.1691415233874;
Mon, 07 Aug 2023 06:33:53 -0700 (PDT)
X-Received: by 2002:a05:6808:190b:b0:3a1:e343:8b51 with SMTP id
bf11-20020a056808190b00b003a1e3438b51mr17420175oib.7.1691415233501; Mon, 07
Aug 2023 06:33:53 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 7 Aug 2023 06:33:53 -0700 (PDT)
In-Reply-To: <75bc1057-8934-44af-911e-cacbbec60bc2n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.123; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.123
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<ual9ur$t6d$1@reader2.panix.com> <89aaec9e-04e9-4b20-8bdc-7e0db8fca358n@googlegroups.com>
<uaqqi0$ijf$1@reader2.panix.com> <75bc1057-8934-44af-911e-cacbbec60bc2n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ab2d57c0-80f1-4729-9fe5-253edb910af4n@googlegroups.com>
Subject: Re: random points near central point
From: profesor...@gmail.com (fir)
Injection-Date: Mon, 07 Aug 2023 13:33:53 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 5298
 by: fir - Mon, 7 Aug 2023 13:33 UTC

poniedziałek, 7 sierpnia 2023 o 15:26:44 UTC+2 fir napisał(a):
> poniedziałek, 7 sierpnia 2023 o 15:13:37 UTC+2 John Forkosh napisał(a):
> > fir <profes...@gmail.com> wrote:
> > > John Forkosh wrote(a):
> > >> fir <profes...@gmail.com> wrote:
> > >> > i need to set asteroids in game (about 100 or 200) but not in square
> > >> > area with two rands one for x and second for y but need it to
> > >> > be sphericel symetric around central point and in more density near it
> > >> > and less desity with bigger radius until some radius when it is zero
> > >> >
> > >> > something like
> > >> > SetRandomPointSphericalSymetricAndFadingWithDistance(
> > >> > float x, float y, float r1, float r2);
> > >> > this r1 is radius of circle below which density is max and r2 is radius
> > >> > where above density is zero - in beetweem r1 and r2 density should
> > >> > be from max (at r1) to zero at r2
> > >> > how to do that?
> > >>
> > >> Haven't read the followups. You mean something like...
> > >> https://www.deviantart.com/eigenheit22/art/Starfield-v1-860092004
> > >> ...without the animation? That's done in x,y (and z). And you can then
> > >> just calculate r=sqrt(x*x+y*y) and discard the ones you don't like..
> > >
> > > possibly - now i think you just can imagine field of discarding
> > > (from 0.0 to 1.0 chance of discarding in given point) then just
> > > calculate chnce of discarding in that point according to a field
> > > and use it
> > >
> > > this is a bit wasteful to count something than discard it but
> > > probably could be enough ok
> > You said 100-200 asteroids, so "wasteful" is hardly a concern.
> > But if you're concerned anyway, suppose you wanted asteroids
> > at radius r1 <= r <= r2 (you wanted "max density" at r<=r1,
> > whereas this will give 0 at r<r1 and r>r2; your exercise is to
> > figure out the necessary modification). So go back to r,theta
> > polar coords and just do something along the following lines...
> > #include <stdlib.h>
> > #include <math.h>
> > void SetRandomPoint( double r1, double r2, double *x, double *y ) {
> > double r = r1 + (r2-r1)*drand48(), /* random r1<=r<r2 */
> > theta = 2.0*3.14159*drand48(); /* random 0<=theta<2pi */
> > *x = r*cos(theta); *y = r*sin(theta); /* return random x,y coords */
> > return; }
> > And the density will naturally decrease with increasing r.
> > No work required.
> i wanted max constand density say in radius 100 then linerally decaying say
> in radius from 300
>
> it seems the rand only givesflat density, then probably proper way fould be to tranmsform/project this square cordinates into other shape as density is proportional to 'surface'if some transforms the surface stretching it or densing by some x,y -> x', y' then it will have les random density
>

this waht you say is in fact such trabsformation x,x->x',y' buts its kinda wrong
becouse near radius zero it has no limited densityand in radius 0.1 you got 10 percent
of all asteroids which simply might be to high..so i gusee there is soem another transformation which coudl be found better..though still its probably a bit harder to write it nly by transformation without discarding

> but i dont remember how to do transformations ([probably they are normal functions of x,y into new x,y so some could be found) but there is also thsi way with making fields of percentage of discarding
>
> this function is handy to me but its also not any way critical i need it jsu to set things in agme liak asteroid fields, space flowers or something liek that (but dont hope it would be look god i only write games wth symbolic graphics, something like kinda roguelikes)

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor