Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

"You need tender loving care once a week - so that I can slap you into shape." -- Ellyn Mustard


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

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

Pages:12
Re: random points near central point

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

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36273&group=comp.lang.c#36273

  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: forkosh@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://news.novabbs.org/devel/article-flat.php?id=36282&group=comp.lang.c#36282

  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.fir@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://news.novabbs.org/devel/article-flat.php?id=36339&group=comp.lang.c#36339

  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.thomasson.1@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://news.novabbs.org/devel/article-flat.php?id=36363&group=comp.lang.c#36363

  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: forkosh@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://news.novabbs.org/devel/article-flat.php?id=36365&group=comp.lang.c#36365

  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.fir@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://news.novabbs.org/devel/article-flat.php?id=36366&group=comp.lang.c#36366

  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.fir@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)

random points near central point

<eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47331&group=comp.lang.c#47331

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:15c3:b0:3f1:fc85:9d74 with SMTP id d3-20020a05622a15c300b003f1fc859d74mr19078qty.6.1689748681156;
Tue, 18 Jul 2023 23:38:01 -0700 (PDT)
X-Received: by 2002:a05:6870:5b14:b0:1ba:7bf5:67a4 with SMTP id
ds20-20020a0568705b1400b001ba7bf567a4mr9123591oab.11.1689748680937; Tue, 18
Jul 2023 23:38:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 18 Jul 2023 23:38:00 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.87; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.87
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
Subject: random points near central point
From: profesor.fir@gmail.com (fir)
Injection-Date: Wed, 19 Jul 2023 06:38:01 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 13
 by: fir - Wed, 19 Jul 2023 06:38 UTC

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?

Re: random points near central point

<c3dced30-da13-423d-8f54-314b8aacecd3n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47335&group=comp.lang.c#47335

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:1992:b0:403:ab15:17a0 with SMTP id u18-20020a05622a199200b00403ab1517a0mr10826qtc.12.1689756540756;
Wed, 19 Jul 2023 01:49:00 -0700 (PDT)
X-Received: by 2002:a05:6830:1359:b0:6b9:91bb:e49e with SMTP id
r25-20020a056830135900b006b991bbe49emr16309353otq.7.1689756540581; Wed, 19
Jul 2023 01:49:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!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: Wed, 19 Jul 2023 01:49:00 -0700 (PDT)
In-Reply-To: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:a5fc:a56:9708:79c3;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:a5fc:a56:9708:79c3
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c3dced30-da13-423d-8f54-314b8aacecd3n@googlegroups.com>
Subject: Re: random points near central point
From: malcolm.arthur.mclean@gmail.com (Malcolm McLean)
Injection-Date: Wed, 19 Jul 2023 08:49:00 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2300
 by: Malcolm McLean - Wed, 19 Jul 2023 08:49 UTC

On Wednesday, 19 July 2023 at 07:38:10 UTC+1, 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?
>
Th easy way to do it is to create three random values on -radius to radius, then calculate
the length with sqrt(x*x + y*y +z*z). If the length is greater thanthe radius, reject and
try again.
Matematicians don't like this because as you scale up to higher dimensions it becomes
less and less efficient.

If yiu want to solve the problem generally, try this link.
https://deepblue.lib.umich.edu/handle/2027.42/35534

Re: random points near central point

<76456298-7ba4-4dcd-887a-d26c492c7b99n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47336&group=comp.lang.c#47336

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:15c4:b0:403:acaa:abe0 with SMTP id d4-20020a05622a15c400b00403acaaabe0mr11020qty.8.1689757160928;
Wed, 19 Jul 2023 01:59:20 -0700 (PDT)
X-Received: by 2002:a05:6870:a881:b0:1b3:99b4:3e46 with SMTP id
eb1-20020a056870a88100b001b399b43e46mr17495069oab.8.1689757160618; Wed, 19
Jul 2023 01:59:20 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 19 Jul 2023 01:59:20 -0700 (PDT)
In-Reply-To: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:a5fc:a56:9708:79c3;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:a5fc:a56:9708:79c3
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <76456298-7ba4-4dcd-887a-d26c492c7b99n@googlegroups.com>
Subject: Re: random points near central point
From: malcolm.arthur.mclean@gmail.com (Malcolm McLean)
Injection-Date: Wed, 19 Jul 2023 08:59:20 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Malcolm McLean - Wed, 19 Jul 2023 08:59 UTC

On Wednesday, 19 July 2023 at 07:38:10 UTC+1, 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?
>
Sorry, I misread your post.

You can probaly get away with caluclating the angle using a uniform random number,
and devising some non-uniform random number for the distance. A curve with a box
out to r1 and a triangle out to r2 wil probably suffice.
You need to integrate the curve, which sounds scary, but all it means is that you need
the area of the box (width time height) and the are of the triangle (hlaf width times
height). That tells you if the unform random number is inthe box or the triangle. If
it's inthe box, it;s a simple division to get how far along the box it is on the x co-ordinate.
If it's in the triangle, it's a bit more involved. You need solve the equation 0.5( 1-x)^2 = p,
where p is your uniform random number, rescaled to lop off the proportion of the box.

Re: random points near central point

<9fc883b7-9b58-4a84-a0b5-97248536a5dcn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47339&group=comp.lang.c#47339

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:590c:0:b0:403:cecf:8c12 with SMTP id 12-20020ac8590c000000b00403cecf8c12mr96208qty.5.1689765604754;
Wed, 19 Jul 2023 04:20:04 -0700 (PDT)
X-Received: by 2002:a05:6870:a892:b0:1b0:21ca:3aff with SMTP id
eb18-20020a056870a89200b001b021ca3affmr2213357oab.5.1689765604525; Wed, 19
Jul 2023 04:20:04 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!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: Wed, 19 Jul 2023 04:20:04 -0700 (PDT)
In-Reply-To: <c3dced30-da13-423d-8f54-314b8aacecd3n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.65; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.65
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com> <c3dced30-da13-423d-8f54-314b8aacecd3n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9fc883b7-9b58-4a84-a0b5-97248536a5dcn@googlegroups.com>
Subject: Re: random points near central point
From: profesor.fir@gmail.com (fir)
Injection-Date: Wed, 19 Jul 2023 11:20:04 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3017
 by: fir - Wed, 19 Jul 2023 11:20 UTC

środa, 19 lipca 2023 o 10:49:09 UTC+2 Malcolm McLean napisał(a):
> On Wednesday, 19 July 2023 at 07:38:10 UTC+1, 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?
> >
> Th easy way to do it is to create three random values on -radius to radius, then calculate
> the length with sqrt(x*x + y*y +z*z). If the length is greater thanthe radius, reject and
> try again.
> Matematicians don't like this because as you scale up to higher dimensions it becomes
> less and less efficient.
>

its okay though as i said i sont need only to have random in circle but gave linearrly more near centre and linearly less far from centre until some radius when i have none

but possibly i can made it with a percent of rejection... i mean count percent of rejection

float percent_of_rejection = (r-r1)(r2-r1); then use it to reject

int do_reject = rand2(0,100)<percent_of_rejection *100;

if(!do_reject)
{ //add
}

something like taht probably its ok, i dont need top efficiency or acurracy its for initialisation of goroups of asteroid or other things like that in 2d space

Re: random points near central point

<20230719001508.499@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47360&group=comp.lang.c#47360

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: random points near central point
Date: Wed, 19 Jul 2023 16:50:54 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <20230719001508.499@kylheku.com>
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
Injection-Date: Wed, 19 Jul 2023 16:50:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="166ade1046392af984099983cd900df5";
logging-data="2358201"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18qnKVGVAV3MtxzrqDgdguI6SDHQXljMYs="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:PIjwb3qo9zfsPnurkg1hV/+6IF4=
 by: Kaz Kylheku - Wed, 19 Jul 2023 16:50 UTC

On 2023-07-19, fir <profesor.fir@gmail.com> wrote:
> where above density is zero - in beetweem r1 and r2 density should
> be from max (at r1) to zero at r2

Kinda like your hydrocephalic melon?

Re: random points near central point

<87tttzr9h0.fsf@bsb.me.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47367&group=comp.lang.c#47367

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: random points near central point
Date: Wed, 19 Jul 2023 20:23:55 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <87tttzr9h0.fsf@bsb.me.uk>
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="728d517973707f8d78d2018e7dcfa5fb";
logging-data="2409509"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18qrM3FAMzjY1rXio+0rlvDDizA7Q78EvU="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:6EIsn7w0fOOKomsD0ZB1YrM6MDw=
sha1:eavWDJNS4Kyxte4AJY2zsbUGZH8=
X-BSB-Auth: 1.4095e840fbcbcedb30bc.20230719202355BST.87tttzr9h0.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 19 Jul 2023 19:23 UTC

fir <profesor.fir@gmail.com> writes:

> 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

If you just pick a uniform angle and a uniform radius and plot those
points, the density of points near the origin will be higher. This is a
very simple method and might be suitable for a game.

> something like
>
> SetRandomPointSphericalSymetricAndFadingWithDistance(
> float x, float y, float r1, float r2);

This suggests that I've not understood your opening paragraph, but I
offer the solution in case someone else might be interested.

> 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?

--
Ben.

Re: random points near central point

<a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47410&group=comp.lang.c#47410

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:f06:b0:762:3d49:c90e with SMTP id v6-20020a05620a0f0600b007623d49c90emr102822qkl.6.1689870684008;
Thu, 20 Jul 2023 09:31:24 -0700 (PDT)
X-Received: by 2002:a05:6870:f80a:b0:1ba:82c3:a56d with SMTP id
fr10-20020a056870f80a00b001ba82c3a56dmr74000oab.1.1689870683486; Thu, 20 Jul
2023 09:31:23 -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, 20 Jul 2023 09:31:23 -0700 (PDT)
In-Reply-To: <87tttzr9h0.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.4; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.4
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com> <87tttzr9h0.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
Subject: Re: random points near central point
From: profesor.fir@gmail.com (fir)
Injection-Date: Thu, 20 Jul 2023 16:31:24 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2581
 by: fir - Thu, 20 Jul 2023 16:31 UTC

środa, 19 lipca 2023 o 21:24:09 UTC+2 Ben Bacarisse napisał(a):
> fir <profes...@gmail.com> writes:
>
> > 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
> If you just pick a uniform angle and a uniform radius and plot those
> points, the density of points near the origin will be higher. This is a
> very simple method and might be suitable for a game.

uniform radius? dont know what is that

generally i need whole pack of functions to set things arndomly but not just in rectangle whuich
will be given by applaying rand to x and y
this spherical group with decaying density with radius is one of that

> > something like
> >
> > SetRandomPointSphericalSymetricAndFadingWithDistance(
> > float x, float y, float r1, float r2);
> This suggests that I've not understood your opening paragraph, but I
> offer the solution in case someone else might be interested.
> > 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?
> --
> Ben.

Re: random points near central point

<874jlyqsi1.fsf@bsb.me.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47416&group=comp.lang.c#47416

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: random points near central point
Date: Thu, 20 Jul 2023 20:42:46 +0100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <874jlyqsi1.fsf@bsb.me.uk>
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<87tttzr9h0.fsf@bsb.me.uk>
<a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="718a5a877a69dbd1318115baaef9d27f";
logging-data="3004857"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CTB/lMRhwpvnr+41XX74/FwVV8AUksTI="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:+CCfQ4oFoWN7rHZf3AnE3dsNvZo=
sha1:PUTEVcp2oouaorSfID0jxkwJnZE=
X-BSB-Auth: 1.c8881667872ca1df0149.20230720204246BST.874jlyqsi1.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 20 Jul 2023 19:42 UTC

fir <profesor.fir@gmail.com> writes:

> środa, 19 lipca 2023 o 21:24:09 UTC+2 Ben Bacarisse napisał(a):
>> fir <profes...@gmail.com> writes:
>>
>> > 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
>> If you just pick a uniform angle and a uniform radius and plot those
>> points, the density of points near the origin will be higher. This is a
>> very simple method and might be suitable for a game.
>
> uniform radius? dont know what is that

Uniform refers to a statistical distribution with uniform density --
every result in some range is equally likely. Your random number
generator will have a function to give you a number uniformly
distributed in some range (often >= 0.0 to < 1.0). I'll use drand48()
as an example.

double pi = 4 * atan(1);
double r = drand48();
double a = 2 * pi * drand48();

Now if you plot the point at angle a and distance r from (0,0) you will
see that they all lie in the unit circle but they cluster round the
origin.

Obviously you can convert polar coordinates r and a to Cartesian x and y
with

double x = r * cos(a), y = r * sin(a);

I'm not sure if this is what you want, but it sounds like it from some
of the words you used.

--
Ben.

Re: random points near central point

<2c181aeb-49e4-45b8-8be1-fc1189878e3en@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47418&group=comp.lang.c#47418

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:4093:b0:767:55c4:572b with SMTP id f19-20020a05620a409300b0076755c4572bmr104740qko.3.1689882964586;
Thu, 20 Jul 2023 12:56:04 -0700 (PDT)
X-Received: by 2002:a05:6808:2018:b0:3a3:644a:b55 with SMTP id
q24-20020a056808201800b003a3644a0b55mr1207069oiw.4.1689882964348; Thu, 20 Jul
2023 12:56:04 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 20 Jul 2023 12:56:03 -0700 (PDT)
In-Reply-To: <874jlyqsi1.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.155; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.155
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<87tttzr9h0.fsf@bsb.me.uk> <a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
<874jlyqsi1.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2c181aeb-49e4-45b8-8be1-fc1189878e3en@googlegroups.com>
Subject: Re: random points near central point
From: profesor.fir@gmail.com (fir)
Injection-Date: Thu, 20 Jul 2023 19:56:04 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 55
 by: fir - Thu, 20 Jul 2023 19:56 UTC

czwartek, 20 lipca 2023 o 21:43:02 UTC+2 Ben Bacarisse napisał(a):
> fir <profes...@gmail.com> writes:
>
> > środa, 19 lipca 2023 o 21:24:09 UTC+2 Ben Bacarisse napisał(a):
> >> fir <profes...@gmail.com> writes:
> >>
> >> > 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
> >> If you just pick a uniform angle and a uniform radius and plot those
> >> points, the density of points near the origin will be higher. This is a
> >> very simple method and might be suitable for a game.
> >
> > uniform radius? dont know what is that
> Uniform refers to a statistical distribution with uniform density --
> every result in some range is equally likely. Your random number
> generator will have a function to give you a number uniformly
> distributed in some range (often >= 0.0 to < 1.0). I'll use drand48()
> as an example.
>
> double pi = 4 * atan(1);
> double r = drand48();
> double a = 2 * pi * drand48();
>
> Now if you plot the point at angle a and distance r from (0,0) you will
> see that they all lie in the unit circle but they cluster round the
> origin.
>
> Obviously you can convert polar coordinates r and a to Cartesian x and y
> with
>
> double x = r * cos(a), y = r * sin(a);
>
> I'm not sure if this is what you want, but it sounds like it from some
> of the words you used.
>

no i just need to add rangom grou[p which is randomly spgerical amd has more density near centre and which get downs to zero at some radius R2
the centre of it (with some radius R) should have some flat density ...iys not just much important what but flad

say i need to put 200 asteroids around some point - in rhe radius say 500 meters they should have 100% density between radius 500 to 1000 metars the density should drop to 0%

Re: random points near central point

<u9c3h4$2rpbs$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47419&group=comp.lang.c#47419

  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.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: random points near central point
Date: Thu, 20 Jul 2023 12:56:19 -0700
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <u9c3h4$2rpbs$1@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: Thu, 20 Jul 2023 19:56:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="548cb02f8621473374aa0fef010fdab5";
logging-data="3007868"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pLfvBTneDZZduOvDbkUCNZekzi9xQa9w="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:sQYFUTpU9QqW2ZY+WMBrUTahowQ=
In-Reply-To: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
Content-Language: en-US
 by: Chris M. Thomasson - Thu, 20 Jul 2023 19:56 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?

Diffuse the points around the central point. This is an example however
it has a bias in the corners of the rotated unit square:

http://fractallife247.com/fdla/

Click around.

Re: random points near central point

<u9c3iv$2rpbs$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47420&group=comp.lang.c#47420

  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.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: random points near central point
Date: Thu, 20 Jul 2023 12:57:18 -0700
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <u9c3iv$2rpbs$2@dont-email.me>
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<87tttzr9h0.fsf@bsb.me.uk>
<a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 19:57:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="548cb02f8621473374aa0fef010fdab5";
logging-data="3007868"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19T201sFUzCkbu/iYJWkSIoR9hYdw/vDHA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:K1wBgnrwRrXZ7GTxAsHdjhQdFfo=
Content-Language: en-US
In-Reply-To: <a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
 by: Chris M. Thomasson - Thu, 20 Jul 2023 19:57 UTC

On 7/20/2023 9:31 AM, fir wrote:
> środa, 19 lipca 2023 o 21:24:09 UTC+2 Ben Bacarisse napisał(a):
>> fir <profes...@gmail.com> writes:
>>
>>> 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
>> If you just pick a uniform angle and a uniform radius and plot those
>> points, the density of points near the origin will be higher. This is a
>> very simple method and might be suitable for a game.
>
> uniform radius? dont know what is that
>
> generally i need whole pack of functions to set things arndomly but not just in rectangle whuich
> will be given by applaying rand to x and y
> this spherical group with decaying density with radius is one of that
>
>>> something like
>>>
>>> SetRandomPointSphericalSymetricAndFadingWithDistance(
>>> float x, float y, float r1, float r2);
>> This suggests that I've not understood your opening paragraph, but I
>> offer the solution in case someone else might be interested.
>>> 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?

Random angles and random radii that are locked in the unit circle?
Should be good enough?

Re: random points near central point

<87sf9ipd5e.fsf@bsb.me.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47421&group=comp.lang.c#47421

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: random points near central point
Date: Thu, 20 Jul 2023 20:59:41 +0100
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <87sf9ipd5e.fsf@bsb.me.uk>
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<87tttzr9h0.fsf@bsb.me.uk>
<a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
<874jlyqsi1.fsf@bsb.me.uk>
<2c181aeb-49e4-45b8-8be1-fc1189878e3en@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="718a5a877a69dbd1318115baaef9d27f";
logging-data="3004857"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18J+Iib3CRWnK+Q4YLx5UW7PTEpMMFSutM="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:1L/YCDD32RiLd7FAcv4Rh9BgUuA=
sha1:hCSBZZn6zuuyPUmkat+X2RNv7HI=
X-BSB-Auth: 1.a26bf535bf190175e4fd.20230720205941BST.87sf9ipd5e.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 20 Jul 2023 19:59 UTC

fir <profesor.fir@gmail.com> writes:

> czwartek, 20 lipca 2023 o 21:43:02 UTC+2 Ben Bacarisse napisał(a):
>> fir <profes...@gmail.com> writes:
>>
>> > środa, 19 lipca 2023 o 21:24:09 UTC+2 Ben Bacarisse napisał(a):
>> >> fir <profes...@gmail.com> writes:
>> >>
>> >> > 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
>> >> If you just pick a uniform angle and a uniform radius and plot those
>> >> points, the density of points near the origin will be higher. This is a
>> >> very simple method and might be suitable for a game.
>> >
>> > uniform radius? dont know what is that
>> Uniform refers to a statistical distribution with uniform density --
>> every result in some range is equally likely. Your random number
>> generator will have a function to give you a number uniformly
>> distributed in some range (often >= 0.0 to < 1.0). I'll use drand48()
>> as an example.
>>
>> double pi = 4 * atan(1);
>> double r = drand48();
>> double a = 2 * pi * drand48();
>>
>> Now if you plot the point at angle a and distance r from (0,0) you will
>> see that they all lie in the unit circle but they cluster round the
>> origin.
>>
>> Obviously you can convert polar coordinates r and a to Cartesian x and y
>> with
>>
>> double x = r * cos(a), y = r * sin(a);
>>
>> I'm not sure if this is what you want, but it sounds like it from some
>> of the words you used.
>
> no i just need to add rangom grou[p which is randomly spgerical amd
> has more density near centre and which get downs to zero at some
> radius R2 the centre of it (with some radius R) should have some flat
> density ...iys not just much important what but flad

I wish you well. If you want to ask in a group where English is widely
used, can you find someone to review your posts? I have no idea what
you are asking, but please don't spend any time explaining it -- I don't
need to know.

--
Ben.

Re: random points near central point

<64228552-63a4-45b2-b332-b29d05967707n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47426&group=comp.lang.c#47426

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:4613:b0:767:2c6f:dc49 with SMTP id br19-20020a05620a461300b007672c6fdc49mr9962qkb.6.1689884284057;
Thu, 20 Jul 2023 13:18:04 -0700 (PDT)
X-Received: by 2002:a05:6870:5a82:b0:1b0:5c0a:c047 with SMTP id
dt2-20020a0568705a8200b001b05c0ac047mr909412oab.2.1689884283833; Thu, 20 Jul
2023 13:18:03 -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, 20 Jul 2023 13:18:03 -0700 (PDT)
In-Reply-To: <u9c3iv$2rpbs$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.155; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.155
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<87tttzr9h0.fsf@bsb.me.uk> <a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
<u9c3iv$2rpbs$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <64228552-63a4-45b2-b332-b29d05967707n@googlegroups.com>
Subject: Re: random points near central point
From: profesor.fir@gmail.com (fir)
Injection-Date: Thu, 20 Jul 2023 20:18:04 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1811
 by: fir - Thu, 20 Jul 2023 20:18 UTC

czwartek, 20 lipca 2023 o 21:57:33 UTC+2 Chris M. Thomasson napisał(a):
> On 7/20/2023 9:31 AM, fir wrote:
> >>> how to do that?
> Random angles and random radii that are locked in the unit circle?
> Should be good enough?

i dont know maybe randomize in circle of R2 then in some steps randomize in smaller circle until i reach R1 ?

there should be some easy methods i guess..hovevver im not sur if geting random in polar coordinates gives really random in 2d space...maybe its natorally more density near centre then?

Re: random points near central point

<60c604ee-8eb2-4748-abba-080c8a7e2faan@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47427&group=comp.lang.c#47427

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:4691:b0:767:f368:7b1d with SMTP id bq17-20020a05620a469100b00767f3687b1dmr9664qkb.9.1689884428186;
Thu, 20 Jul 2023 13:20:28 -0700 (PDT)
X-Received: by 2002:a9d:480a:0:b0:6b9:5bfc:9b33 with SMTP id
c10-20020a9d480a000000b006b95bfc9b33mr5401968otf.6.1689884427882; Thu, 20 Jul
2023 13:20:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.1d4.us!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, 20 Jul 2023 13:20:27 -0700 (PDT)
In-Reply-To: <874jlyqsi1.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.155; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.155
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<87tttzr9h0.fsf@bsb.me.uk> <a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
<874jlyqsi1.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <60c604ee-8eb2-4748-abba-080c8a7e2faan@googlegroups.com>
Subject: Re: random points near central point
From: profesor.fir@gmail.com (fir)
Injection-Date: Thu, 20 Jul 2023 20:20:28 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3284
 by: fir - Thu, 20 Jul 2023 20:20 UTC

czwartek, 20 lipca 2023 o 21:43:02 UTC+2 Ben Bacarisse napisał(a):
> fir <profes...@gmail.com> writes:
>
> > środa, 19 lipca 2023 o 21:24:09 UTC+2 Ben Bacarisse napisał(a):
> >> fir <profes...@gmail.com> writes:
> >>
> >> > 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
> >> If you just pick a uniform angle and a uniform radius and plot those
> >> points, the density of points near the origin will be higher. This is a
> >> very simple method and might be suitable for a game.
> >
> > uniform radius? dont know what is that
> Uniform refers to a statistical distribution with uniform density --
> every result in some range is equally likely. Your random number
> generator will have a function to give you a number uniformly
> distributed in some range (often >= 0.0 to < 1.0). I'll use drand48()
> as an example.
>
> double pi = 4 * atan(1);
> double r = drand48();
> double a = 2 * pi * drand48();
>
> Now if you plot the point at angle a and distance r from (0,0) you will
> see that they all lie in the unit circle but they cluster round the
> origin.
>
> Obviously you can convert polar coordinates r and a to Cartesian x and y
> with
>
> double x = r * cos(a), y = r * sin(a);
>
> I'm not sure if this is what you want, but it sounds like it from some
> of the words you used.
>

you mean hust getting random radius + random angle tend to do more density for smal radius - you may be right... i didnt get it in fiorst moment...yjere may be some problem though that it provides to high density near centra and here i need tio have flat density not linearly rise till zero

Re: random points near central point

<u9db6n$359g5$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47453&group=comp.lang.c#47453

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.brown@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: random points near central point
Date: Fri, 21 Jul 2023 09:13:27 +0200
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <u9db6n$359g5$1@dont-email.me>
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<87tttzr9h0.fsf@bsb.me.uk>
<a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
<874jlyqsi1.fsf@bsb.me.uk>
<2c181aeb-49e4-45b8-8be1-fc1189878e3en@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 21 Jul 2023 07:13:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b2fb03a98f308a462982357442f9ec83";
logging-data="3319301"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191JT1wUf1IuYznYLv1E/S3DiMcdzCvTKg="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:7xZmnyFKt/fd6/QWSwY0c+VUKBI=
In-Reply-To: <2c181aeb-49e4-45b8-8be1-fc1189878e3en@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Fri, 21 Jul 2023 07:13 UTC

On 20/07/2023 21:56, fir wrote:
> czwartek, 20 lipca 2023 o 21:43:02 UTC+2 Ben Bacarisse napisał(a):
>> fir <profes...@gmail.com> writes:
>>
>>> środa, 19 lipca 2023 o 21:24:09 UTC+2 Ben Bacarisse napisał(a):
>>>> fir <profes...@gmail.com> writes:
>>>>
>>>>> 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
>>>> If you just pick a uniform angle and a uniform radius and plot those
>>>> points, the density of points near the origin will be higher. This is a
>>>> very simple method and might be suitable for a game.
>>>
>>> uniform radius? dont know what is that
>> Uniform refers to a statistical distribution with uniform density --
>> every result in some range is equally likely. Your random number
>> generator will have a function to give you a number uniformly
>> distributed in some range (often >= 0.0 to < 1.0). I'll use drand48()
>> as an example.
>>
>> double pi = 4 * atan(1);
>> double r = drand48();
>> double a = 2 * pi * drand48();
>>
>> Now if you plot the point at angle a and distance r from (0,0) you will
>> see that they all lie in the unit circle but they cluster round the
>> origin.
>>
>> Obviously you can convert polar coordinates r and a to Cartesian x and y
>> with
>>
>> double x = r * cos(a), y = r * sin(a);
>>
>> I'm not sure if this is what you want, but it sounds like it from some
>> of the words you used.
>>
>
> no i just need to add rangom grou[p which is randomly spgerical amd has more density near centre and which get downs to zero at some radius R2
> the centre of it (with some radius R) should have some flat density ...iys not just much important what but flad
>
> say i need to put 200 asteroids around some point - in rhe radius say 500 meters they should have 100% density between radius 500 to 1000 metars the density should drop to 0%

const double outer_radius = 1000;
const double inner_radius = 1000;

const double pi = 4 * atan(1);

double distance_to_asteroid = drand48() * (outer_radius - inner_radius)
+ inner_radius;
double angle_in_radians = 2 * pi * drand48();

Does that help?

If not, I'm with Ben - if you want help, you'll have to explain the task
better, and explain why this won't work.

Re: random points near central point

<0c4b6149-511e-432c-a5b7-c7c88a865006n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47470&group=comp.lang.c#47470

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:b883:0:b0:767:f102:e564 with SMTP id i125-20020a37b883000000b00767f102e564mr3761qkf.12.1689944127796;
Fri, 21 Jul 2023 05:55:27 -0700 (PDT)
X-Received: by 2002:a9d:664f:0:b0:6b9:4d78:cf07 with SMTP id
q15-20020a9d664f000000b006b94d78cf07mr3283044otm.7.1689944127380; Fri, 21 Jul
2023 05:55:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!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, 21 Jul 2023 05:55:26 -0700 (PDT)
In-Reply-To: <u9db6n$359g5$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.108; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.108
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<87tttzr9h0.fsf@bsb.me.uk> <a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
<874jlyqsi1.fsf@bsb.me.uk> <2c181aeb-49e4-45b8-8be1-fc1189878e3en@googlegroups.com>
<u9db6n$359g5$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0c4b6149-511e-432c-a5b7-c7c88a865006n@googlegroups.com>
Subject: Re: random points near central point
From: profesor.fir@gmail.com (fir)
Injection-Date: Fri, 21 Jul 2023 12:55:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 5353
 by: fir - Fri, 21 Jul 2023 12:55 UTC

piątek, 21 lipca 2023 o 09:15:59 UTC+2 David Brown napisał(a):
> On 20/07/2023 21:56, fir wrote:
> > czwartek, 20 lipca 2023 o 21:43:02 UTC+2 Ben Bacarisse napisał(a):
> >> fir <profes...@gmail.com> writes:
> >>
> >>> środa, 19 lipca 2023 o 21:24:09 UTC+2 Ben Bacarisse napisał(a):
> >>>> fir <profes...@gmail.com> writes:
> >>>>
> >>>>> 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
> >>>> If you just pick a uniform angle and a uniform radius and plot those
> >>>> points, the density of points near the origin will be higher. This is a
> >>>> very simple method and might be suitable for a game.
> >>>
> >>> uniform radius? dont know what is that
> >> Uniform refers to a statistical distribution with uniform density --
> >> every result in some range is equally likely. Your random number
> >> generator will have a function to give you a number uniformly
> >> distributed in some range (often >= 0.0 to < 1.0). I'll use drand48()
> >> as an example.
> >>
> >> double pi = 4 * atan(1);
> >> double r = drand48();
> >> double a = 2 * pi * drand48();
> >>
> >> Now if you plot the point at angle a and distance r from (0,0) you will
> >> see that they all lie in the unit circle but they cluster round the
> >> origin.
> >>
> >> Obviously you can convert polar coordinates r and a to Cartesian x and y
> >> with
> >>
> >> double x = r * cos(a), y = r * sin(a);
> >>
> >> I'm not sure if this is what you want, but it sounds like it from some
> >> of the words you used.
> >>
> >
> > no i just need to add rangom grou[p which is randomly spgerical amd has more density near centre and which get downs to zero at some radius R2
> > the centre of it (with some radius R) should have some flat density ...iys not just much important what but flad
> >
> > say i need to put 200 asteroids around some point - in rhe radius say 500 meters they should have 100% density between radius 500 to 1000 metars the density should drop to 0%
> const double outer_radius = 1000;
> const double inner_radius = 1000;
>
> const double pi = 4 * atan(1);
>
> double distance_to_asteroid = drand48() * (outer_radius - inner_radius)
> + inner_radius;
> double angle_in_radians = 2 * pi * drand48();
>
> Does that help?
>
> If not, I'm with Ben - if you want help, you'll have to explain the task
> better, and explain why this won't work.

help is wrong word here i state topic, as opportunity to say something, dont need help
in a strict sense of this world - one need help if has a serious problem he cant overcome and
that kind of things is not like that

btw better write int rand2(int min, int max) function as i do, using this naked form is generally stupid imo

no i dont want to put an asteroid in 'cylinder' from radius r1 to r2
i want to set most of them in circle r1 and rest in cylinder from r1 to r2 such way it would look naturally such as a n group of astronomical things or pieces of things when you shatter them on the floor - most density in the centre till r1 less near r2 and none outside r2

this one with just
for(int i=0; i<200;i++) { r = rand2(r1,r2); a = rand2(1,360); }

i yet not tested but i got a feeling it isnt enough good (will test in evening)
probably something like said

for(float r=r2; i<r1; r-=(r2-r1)/200.)
{
PutRandomInCurcle(z,y,r);
}

could be somewhat better (It puts random in circle which is shrinking thus the edges will have less then centre

Re: random points near central point

<70c10615-2473-4f66-ab1c-c632aa33fa5cn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47550&group=comp.lang.c#47550

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:1827:b0:403:f563:30e1 with SMTP id t39-20020a05622a182700b00403f56330e1mr14812qtc.10.1690053855783;
Sat, 22 Jul 2023 12:24:15 -0700 (PDT)
X-Received: by 2002:a05:6808:1b0b:b0:3a0:3d3c:1f03 with SMTP id
bx11-20020a0568081b0b00b003a03d3c1f03mr10069740oib.11.1690053855474; Sat, 22
Jul 2023 12:24:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sat, 22 Jul 2023 12:24:15 -0700 (PDT)
In-Reply-To: <0c4b6149-511e-432c-a5b7-c7c88a865006n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:5f82:5000:f1f2:a13a:10ef:2ba;
posting-account=3ty6FAkAAACYEfch20jQ1ZACFatw-Vdx
NNTP-Posting-Host: 2600:1700:5f82:5000:f1f2:a13a:10ef:2ba
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<87tttzr9h0.fsf@bsb.me.uk> <a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
<874jlyqsi1.fsf@bsb.me.uk> <2c181aeb-49e4-45b8-8be1-fc1189878e3en@googlegroups.com>
<u9db6n$359g5$1@dont-email.me> <0c4b6149-511e-432c-a5b7-c7c88a865006n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <70c10615-2473-4f66-ab1c-c632aa33fa5cn@googlegroups.com>
Subject: Re: random points near central point
From: edprochak@gmail.com (Ed Prochak)
Injection-Date: Sat, 22 Jul 2023 19:24:15 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Ed Prochak - Sat, 22 Jul 2023 19:24 UTC

On Friday, July 21, 2023 at 8:55:36 AM UTC-4, fir wrote:
[]
> no i dont want to put an asteroid in 'cylinder' from radius r1 to r2
> i want to set most of them in circle r1 and rest in cylinder from r1 to r2
> such way it would look naturally such as a n group of astronomical things
> or pieces of things when you shatter them on the floor - most density in
> the centre till r1 less near r2 and none outside r2
>
I suggest you define your expected distribution first.
You might begin by defining the distribution you really want.
case 1: Is it constant density from 0 to r1 and then linear decline of density from r` to r2?
case 2: is is a natural distribution of "astronomical things"?
(clearly not like case 1, consider the solar system, including the asteroid belt)
case 3: is it a random scattering as "when you shatter them on the floor"
(clearly not like case 1 or 2. This is a gaussian distribution.)
case 4: SOMETHING ELSE???

State your desire clearly and we may be able to help you. Without a clear goal,
you'll be debugging potential solutions forever.

Ed

Re: random points near central point

<f95fe6e8-b77b-42ba-a3d9-78057e1101c0n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47581&group=comp.lang.c#47581

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:5f92:0:b0:403:edaf:5b78 with SMTP id j18-20020ac85f92000000b00403edaf5b78mr17786qta.6.1690110285483;
Sun, 23 Jul 2023 04:04:45 -0700 (PDT)
X-Received: by 2002:a05:6870:5b19:b0:1ba:50ed:9ed6 with SMTP id
ds25-20020a0568705b1900b001ba50ed9ed6mr9064402oab.2.1690110285323; Sun, 23
Jul 2023 04:04:45 -0700 (PDT)
Path: i2pn2.org!i2pn.org!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: Sun, 23 Jul 2023 04:04:44 -0700 (PDT)
In-Reply-To: <70c10615-2473-4f66-ab1c-c632aa33fa5cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.243; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.243
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<87tttzr9h0.fsf@bsb.me.uk> <a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
<874jlyqsi1.fsf@bsb.me.uk> <2c181aeb-49e4-45b8-8be1-fc1189878e3en@googlegroups.com>
<u9db6n$359g5$1@dont-email.me> <0c4b6149-511e-432c-a5b7-c7c88a865006n@googlegroups.com>
<70c10615-2473-4f66-ab1c-c632aa33fa5cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f95fe6e8-b77b-42ba-a3d9-78057e1101c0n@googlegroups.com>
Subject: Re: random points near central point
From: profesor.fir@gmail.com (fir)
Injection-Date: Sun, 23 Jul 2023 11:04:45 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3571
 by: fir - Sun, 23 Jul 2023 11:04 UTC

sobota, 22 lipca 2023 o 21:24:23 UTC+2 Ed Prochak napisał(a):
> On Friday, July 21, 2023 at 8:55:36 AM UTC-4, fir wrote:
> []
> > no i dont want to put an asteroid in 'cylinder' from radius r1 to r2
> > i want to set most of them in circle r1 and rest in cylinder from r1 to r2
> > such way it would look naturally such as a n group of astronomical things
> > or pieces of things when you shatter them on the floor - most density in
> > the centre till r1 less near r2 and none outside r2
> >
> I suggest you define your expected distribution first.
> You might begin by defining the distribution you really want.
> case 1: Is it constant density from 0 to r1 and then linear decline of density from r` to r2?
> case 2: is is a natural distribution of "astronomical things"?
> (clearly not like case 1, consider the solar system, including the asteroid belt)
> case 3: is it a random scattering as "when you shatter them on the floor"
> (clearly not like case 1 or 2. This is a gaussian distribution.)
> case 4: SOMETHING ELSE???
>
> State your desire clearly and we may be able to help you. Without a clear goal,
> you'll be debugging potential solutions forever.
>
> Ed

i dont care to much exactly i need to set a pack of 200 asteroids around some point to look good (but this should be not to much density in centre, ilke 10 asteroid cover the same piece of screen, thety may cover partially, but not like stack in 10 in one place)...also i want to use this function to set other things like in random group (but not like brush in pain, its more like more density in centre (where centre is not point but circle) and gradually less from r1 to r2

i think its not hard to understand what i want

in fact i may need more on this like some function tos et random 'stars' points in color/colors to make something that would look like nice looking photographs of galexies, making nice looking random groups (for a use of 2d cosmic space game)

Re: random points near central point

<87fs5en385.fsf@bsb.me.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=47596&group=comp.lang.c#47596

  copy link   Newsgroups: comp.lang.c comp.programming
Followup: comp.programming
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c,comp.programming
Subject: Re: random points near central point
Followup-To: comp.programming
Date: Sun, 23 Jul 2023 14:53:46 +0100
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <87fs5en385.fsf@bsb.me.uk>
References: <eb9e82fb-265b-42a7-a245-1943e5b3b5aan@googlegroups.com>
<87tttzr9h0.fsf@bsb.me.uk>
<a0756188-052d-406b-8fe8-7c6a071be044n@googlegroups.com>
<874jlyqsi1.fsf@bsb.me.uk>
<2c181aeb-49e4-45b8-8be1-fc1189878e3en@googlegroups.com>
<u9db6n$359g5$1@dont-email.me>
<0c4b6149-511e-432c-a5b7-c7c88a865006n@googlegroups.com>
<70c10615-2473-4f66-ab1c-c632aa33fa5cn@googlegroups.com>
<f95fe6e8-b77b-42ba-a3d9-78057e1101c0n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="46eee68be2a45be2a6fdd3ba499a7b10";
logging-data="295049"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XvSd1tGP7oHY4K1V8Vo2ovYDsDOMYEjk="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:OWg5nFpO7W6wL/6qkKZORI/9pPk=
sha1:iHGJaM25uf4CnNcIB/1Ecsf/eG8=
X-BSB-Auth: 1.2e4158c84944d26a49aa.20230723145346BST.87fs5en385.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 23 Jul 2023 13:53 UTC

fir <profesor.fir@gmail.com> writes:

> sobota, 22 lipca 2023 o 21:24:23 UTC+2 Ed Prochak napisał(a):
>> On Friday, July 21, 2023 at 8:55:36 AM UTC-4, fir wrote:
>> []
>> > no i dont want to put an asteroid in 'cylinder' from radius r1 to r2
>> > i want to set most of them in circle r1 and rest in cylinder from r1 to r2
>> > such way it would look naturally such as a n group of astronomical things
>> > or pieces of things when you shatter them on the floor - most density in
>> > the centre till r1 less near r2 and none outside r2
>> >
>> I suggest you define your expected distribution first.
>> You might begin by defining the distribution you really want.
>> case 1: Is it constant density from 0 to r1 and then linear decline of density from r` to r2?
>> case 2: is is a natural distribution of "astronomical things"?
>> (clearly not like case 1, consider the solar system, including the asteroid belt)
>> case 3: is it a random scattering as "when you shatter them on the floor"
>> (clearly not like case 1 or 2. This is a gaussian distribution.)
>> case 4: SOMETHING ELSE???
>>
>> State your desire clearly and we may be able to help you. Without a clear goal,
>> you'll be debugging potential solutions forever.
>>
>> Ed
>
> i dont care to much exactly i need to set a pack of 200 asteroids
> around some point to look good (but this should be not to much density
> in centre, ilke 10 asteroid cover the same piece of screen, thety may
> cover partially, but not like stack in 10 in one place)...also i want
> to use this function to set other things like in random group (but not
> like brush in pain, its more like more density in centre (where centre
> is not point but circle) and gradually less from r1 to r2

A bit like these:

http://bsb.me.uk/tmp/r1.png
http://bsb.me.uk/tmp/r2.png

> i think its not hard to understand what i want

It's hard to understand what you write. I am sure what you want is
quite simple. This is not about C so I'm going to crosspost to
comp.programming and set followups. I won't post about it here again.

--
Ben.

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor