[SciPy-User] random points within an ellipse
Wed Aug 4 22:13:03 CDT 2010
On Wed, Aug 4, 2010 at 7:18 PM, alex <firstname.lastname@example.org> wrote:
> On Wed, Aug 4, 2010 at 7:38 PM, Benjamin Root <email@example.com> wrote:
>> For a project, I need to create sets of random coordinates within a 2d
>> domain. To start, I have been creating random x and y coordinates, which
>> has worked very nicely. However, I would like to start doing some fancier
>> domains like ellipses and crescents. Does anybody know of any useful tricks
>> for doing this?
>> Ben Root
> For an ellipse you could start with random points in a disk like this
> and then I think you can just stretch along an axis to give the points
> inside the ellipse disk.
> For fancier shapes you can do rejection sampling as long as you can get a
> bounding box and
> you can tell what is inside vs outside the domain.
Thanks Alex, that certainly does put me in the correct direction. It appears
that there isn't an analogous expression for an ellipse as there was for a
disc. I probably will have to just take your suggestion and do some
scaling/rotation upon the set of points to get what I want. It should be
more than sufficient, and it does look better than my original attempts.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User