作者Leon (Achilles)
站内MATLAB
标题Re: [讨论] 圆内随机取N个座标点的问题
时间Tue Aug 14 02:50:14 2012
※ 引述《tomichy (绝倒!天然度max!)》之铭言:
: 我想这应该是个归类为演算法的问题吧?
: 我利用简单的关系式
: X=r*cos(theta)+a & Y=r*sin(theta)+b, 0<=r<=R
: 在一个半径R的圆内 任意指定N个座标点 (N large)
: 随机变数有 r 以及theta 两个 分别随机取然後得到(X,Y)
: "以如此方式产生的座标点(X,Y)的密度靠近(a,b)的区域
: 相对於其他地方都来得高"
: (以座标点密度对半径作图, 会类似常态分布)
: 而这不是我想要的结果
你做错了
因为两个作标系统的 Jocobian, 你得去查 学一下这个作标函数转换
这应该在微积分有.
Quick hint: unit area in (x,y) is dx*dy
but in (r, theta) is r dr*d(theta)
: 请问各位有没有经验或可以明示一下
: 如果想写一个 when N large
: 在圆内座标点几何分布密度会趋近於定值的的一个座标指定方式
: (以座标点密度对半径作图, 呈现接近水平线)
It's not correct.
If you want uniform inside circule area, the
density should be prop to r.
There are so fancy methods here.
Google is always your best friend.
http://stackoverflow.com/questions/5837572/generate-a-random-point-within-a-circle-uniformly
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 205.226.66.120
1F:推 tomichy:赞 你这个回答(网页)是我想要的~ thx 08/22 14:39