[Date Index]
[Thread Index]
[Author Index]
Re: random points!
*To*: mathgroup at smc.vnet.net
*Subject*: [mg80985] Re: random points!
*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
*Date*: Thu, 6 Sep 2007 05:43:51 -0400 (EDT)
*Organization*: The Open University, Milton Keynes, UK
*References*: <fblj4r$p97$1@smc.vnet.net>
dimitris wrote:
> I have the following drawing
> (it is just a part of a bigger figure...)
>
> In[125]:=
> surface = Graphics[{Thickness[0.0079], Line[{{-3.1, 0}, {3, 0}}]}];
> halfcir = Graphics[{Thickness[0.0079], Circle[{0, 0}, 0.6, {Pi,
> 2*Pi}]}];
> randpoints = Table[Graphics[{PointSize[0.012], Point[{Random[Real,
> {-0.42, 0.42}], Random[Real, {-0.01, -0.47}]}]}], {300}];
> Show[surface, halfcir, randpoints, AspectRatio -> Automatic];
>
> How can I add as much points as possible inside the half-circle
> (so that there are not so big white regions as in the previous
> drawing)
> assuring that they are not situated outside it?
>
> I think something has to be modified for randpoints above in order to
> be included
> a rule but currently I can't think sth.
Hi Dimitris,
The rule you are looking for is related to the disk point picking
problem [1]. The following version of randpoints should behave as expected.
In[1]:=
surface =
Graphics[{Thickness[0.0079], Line[{{-3.1, 0}, {3, 0}}]}];
halfcir =
Graphics[{Thickness[0.0079], Circle[{0, 0}, 0.6, {Pi, 2*Pi}]}];
randpoints =
Table[
Graphics[{
PointSize[0.012],
Point[
Block[{r, theta},
r = Random[Real, {0, 0.36}];
theta = Random[Real, {Pi, 2*Pi}];
Sqrt[r]*{Cos[theta], Sin[theta]}]]}], {300}];
Show[surface, halfcir, randpoints, AspectRatio -> Automatic];
Best regards,
--
Jean-Marc
[1] Weisstein, Eric W. "Disk Point Picking." From MathWorld--A Wolfram
Web Resource. http://mathworld.wolfram.com/DiskPointPicking.html
Prev by Date:
**Re: Incorrect, misleading, "Operate Directly on Graphics" example.**
Next by Date:
**Re: How to compile this module?**
Previous by thread:
**Re: random points!**
Next by thread:
**Re: random points!**
| |