Re: random points!
- To: mathgroup at smc.vnet.net
- Subject: [mg80972] Re: [mg80892] random points!
- From: DrMajorBob <drmajorbob at bigfoot.com>
- Date: Thu, 6 Sep 2007 05:37:11 -0400 (EDT)
- References: <1465214.1189001087813.JavaMail.root@m35>
- Reply-to: drmajorbob at bigfoot.com
First, I'd suggest Disk, not Circle:
surface = Graphics[{Thickness[0.0079], Line[{{-3.1, 0}, {3, 0}}]}];
halfcir =
Graphics[{Thickness[0.0079], Disk[{0, 0}, 0.6, {Pi, 2 Pi}]}];
Show[surface, halfcir, AspectRatio -> Automatic]
If you really want random points in the half-circle, the problem is their
placement, not their number. Maybe this is closer to what you want:
Clear[pt, pts]
pt[_] := Point@
Through[{Re,
Im}@(RandomReal[{0, .6}] Exp[I RandomReal[{Pi, 2 Pi}]])]
pts[n_] := Graphics at {PointSize[.012], Array[pt, n]}
surface = Graphics[{Thickness[0.0079], Line[{{-3.1, 0}, {3, 0}}]}];
halfcir =
Graphics[{Thickness[0.0079], Circle[{0, 0}, 0.6, {Pi, 2 Pi}]}];
Show[surface, halfcir, pts[500], AspectRatio -> Automatic]
or (to prevent points sneaking past the boundaries):
Clear[pt, pts]
ptsize = .012;
pt[_] := Point@
Through[{Re,
Im}@(RandomReal[{0, .6 - 2 ptsize}]
Exp[I RandomReal[{Pi, 2 Pi}]])]
pts[n_] :=
Graphics@{PointSize[ptsize],
DeleteCases[Array[pt, n], Point[{_, y_}] /; y > -2 ptsize]}
surface = Graphics[{Thickness[0.0079], Line[{{-3.1, 0}, {3, 0}}]}];
halfcir =
Graphics[{Thickness[0.0079], Circle[{0, 0}, 0.6, {Pi, 2 Pi}]}];
Show[surface, halfcir, pts[500], AspectRatio -> Automatic]
Bobby
On Wed, 05 Sep 2007 01:46:19 -0500, dimitris <dimmechan at yahoo.com> wrote=
:
> Hello.
>
> 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.
>
> Thanks
> Dimitris
>
>
>
-- =
DrMajorBob at bigfoot.com