美文网首页
不同形状内的均匀采样

不同形状内的均匀采样

作者: YanyZhao | 来源:发表于2020-12-03 22:29 被阅读0次

1. 两椭圆间采样

for i = 0:3000
    r = 80;
    R = 120;
    rr = rand * (R * R - r * r) + r * r;
    rr = sqrt(rr);
    theta = -pi/2 + pi*rand; %[-pi/2,pi/2]随机角度
    if mod(round(rr),2) == 0
        scatter(rr * cos(theta+pi/6),rr * sin(theta+pi/6) / 4,5,[0 0 1],'filled');
    else
        scatter(-rr * cos(theta+pi/6),-rr * sin(theta+pi/6) / 4,5,[0 0 1],'filled');
    end
  hold on;
end
两椭圆间采样
2. 椭圆绘制
Num=100;
cicle=zeros(Num,2);
a=60;%长半轴
b=30;%短半轴
for i=1:Num
    theta=-pi+i/Num*2*pi;
    dOP=a*b/sqrt(a^2*sin(theta)^2+b^2*cos(theta)^2);
    cicle(i,:)= dOP*[cos(theta+pi/6) sin(theta+pi/6)];
end
plot(cicle(:,1),cicle(:,2),'k','linewidth',1,'linestyle','--');
%fill(cicle(:,1)+80,cicle(:,2)-150,'g');%填充颜色
axis equal
椭圆绘制
3. 椭圆均匀采样
% % % 作者:西边升起太阳
% % % 链接:https://www.zhihu.com/question/277712372/answer/550002849
% % % 来源:知乎
% % % 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
% % % 参考:Informed RRT*: Optimal Incremental Path Planning Focused through an Admissible Ellipsoidal Heuristic
%坐标系正常
clc
clear
time=0;
 start=[0,0];
 goal=[20,50];
% start=[13 13]; % source position in Y, X format
% goal=[42 32]; % goal position in Y, X format
cmin=norm(goal-start);
cbest=120;
axis([-100,100,-100,100])
scatter(start(1),start(2),100,[0 1 0],'filled');
hold on;
scatter(goal(1),goal(2),100,[1 0 0],'filled');
hold on;
set(gcf,'position',[0.1,0.1,500,500])
time=0;
while time<500 
    %内部点均匀采样:圆→椭圆
    x_center=[(start+goal)/2,0];    
    x_center=x_center';    
    a_1=[(goal(1)-start(1))/cmin;(goal(2)-start(2))/cmin;0];    
    id_t=[1,0,0];    
    M=a_1*id_t;    
    [U,S,Vh]=svd(M);    
    C=(U*diag([1,1,det(U)*det(Vh')]))*(Vh);    
    r=[cbest/2,sqrt(cbest.^2-cmin.^2)/2,sqrt(cbest.^2-cmin.^2)/2];    
    L=diag(r);    a=rand();    b=rand();    
    if b<a        
        tmp=b;        
        b=a;        
        a=tmp;    
    end
    x_ball=[b*cos(2*pi*a/b);b*sin(2*pi*a/b);0];    
    randpoint=C*L*x_ball+x_center;    
    scatter(randpoint(1,1),randpoint(2,1),'.','b')    
    hold on     
    grid on    
    %绘制外围椭圆边界
    if time==200
        for i=1:500
            theta=-pi+i/500*2*pi;
            y_ball=[cos(theta);sin(theta);0]; 
            ellipse_bound(i,:,:)=(C*L*y_ball+x_center)';
            plot(ellipse_bound(:,1),ellipse_bound(:,2),'k','linewidth',2,'linestyle','--') 
            hold on
        end 
    end
    time=time+1;
end
椭圆均匀采样
3. 单位球内均匀采样
    %单位球内采样 
    phi = rand().*2*pi;
    costheta = -1+rand()*2;
    u = rand();
    theta = acos(costheta)
    r = 1*u^(1/3);
    x_ball=[r*(sin(theta).*cos(phi));r*(sin(theta).*sin(phi));r*cos(theta);]; 

相关文章

  • 不同形状内的均匀采样

    1. 两椭圆间采样[http://jsfiddle.net/SQERh/] 2. 椭圆绘制 3. 椭圆均匀采样 3...

  • 圆盘均匀采样

    考虑在半径为1的圆盘上均匀的取随机点应该怎么做? Rejection Sampling 首先想象有一个2X2的单位...

  • PointRend实现细节

    如何选择采样点? 从均匀分布随机采样kN个点 重点采样BN个点 从均匀分布中采样(1-B)N个点 def get_...

  • 12.4 非均匀采样

    沿着k-space数据的任何一个方向,都存在这样的因素,涡流,模数转换误差,时间调换误差,这些都会导致数据的非均匀...

  • 点云采样

    原文链接 点云采样分类 点云采样的方法有很多种,常见的有均匀采样,几何采样,随机采样,格点采样等。下面介绍一些常见...

  • 概率简要学习记录

    随机数问题 构造均匀的随机数发生器 要等概率才可以丢掉 不均匀的随机数产生器 采样问题 水库采样利用数组和随机数取...

  • Android视音频基础知识

    学术概念 采样和采样频率: ⼀秒钟内采样的次数称为采样频率。采样频率越⾼,越接近原始信号,但是也加⼤了运算处理的复...

  • 2019-03-28

    对于简单函数的分布,如均匀分布,高斯分布等,很多编程语言有直接的采样函数; 复杂的分布,往往没有直接的采样函数可供...

  • Arxiv网络科学论文摘要4篇(2019-01-17)

    州际战争的频率和严重程度; 超越均匀反向采样:一种用于预防错误信息的混合采样技术; 基于局部边度的加权标签传播算法...

  • 新会陈皮

    常呈三瓣相连,或四瓣成十字形状相连,形状整齐,厚度均匀;外表面呈棕红色、橙红色或青黄色,有皱纹,密布凹孔状油胞;内...

网友评论

      本文标题:不同形状内的均匀采样

      本文链接:https://www.haomeiwen.com/subject/dfwvwktx.html