function x_est = CAB(A, r, R)
B = A(:, r~=0);%filter the pseudo-circles with radius of 0
r1 = r(r~=0);
center = [B A];
radius = [r1; R];
n = length(radius);
tolerance = 1e-5; % this parameter is used to cancel the impact of numerical accuracy.
intersect_point = [];
for i = 1:n-1
for j = i+1:n
a1 = center(:,i);
a2 = center(:,j);
if norm(a1-a2)==0
continue;
end
r1 = radius(i);
r2 = radius(j);
pp = intersect(a1, a2, r1, r2);
intersect_point = [intersect_point pp];
end
end
if length(intersect_point)==0
error('all circles do not intersect each other', '%s', 'exceptional case');
end
m = length(r);
n = size(intersect_point, 2);
degree = zeros(n, 1);
for i=1:n
pp = intersect_point(:,i);
for j=1:m
dist = norm(pp-A(:,j));
if dist<=R(j)+tolerance & dist>=r(j)-tolerance
degree(i) = degree(i)+1;
end
end
end
%degree
valid_intersect_point = [];
if max(degree)==m %the feasible case
valid_intersect_point = intersect_point(:, degree==m);
x_est = mean(valid_intersect_point, 2);
else
%TPDS method in random walk case
%%select k points with highest degree in the infeasible case
%[deg, index] = sort(degree, 'descend');
%k = 3;%assume k=3, that is, the first three points are selected to estimate the position of unknown node, but you can vary k to obtain different estimation performance
%x_est = mean(intersect_point(:, index(1:k)), 2);
%variant of TPDS method
%select all points with highest degree in the feasible case
valid_intersect_point = intersect_point(:, degree==max(degree));
x_est = mean(valid_intersect_point, 2);
end
return
function pp = intersect(a1, a2, r1, r2)
x1 = a1(1); y1 = a1(2);
x2 = a2(1); y2 = a2(2);
t = (x1^2+y1^2)-(x2^2+y2^2)-r1^2+r2^2;
bx = 2*(x1-x2); by = 2*(y1-y2);
d = r1^2-x1^2-y1^2;
if bx==0%the exceptional case
y = t/by;
a = 1;
b = -2*x1;
c = -d+y^2-2*y*y1;
temp = b^2-4*a*c;
if temp==0
x = -b/(2*a);
pp = [x; y];
elseif temp>0
x = (-b+sqrt(temp))/(2*a);
p1 = [x; y];
x = (-b-sqrt(temp))/(2*a);
p2 = [x; y];
pp = [p1 p2];
else
pp = [];
end
return;
end
a = (by/bx)^2+1;
b = -2*by*t/bx^2+2*x1*by/bx-2*y1;
c = (t/bx)^2-2*x1*t/bx-d;
temp = b^2-4*a*c;
if temp==0%only one intersection point
y = -b/(2*a);
x = (t-by*y)/bx;
pp = [x; y];
elseif temp>0%two intersection points
y = (-b+sqrt(temp))/(2*a);
x = (t-by*y)/bx;
p1 = [x; y];
y = (-b-sqrt(temp))/(2*a);
x = (t-by*y)/bx;
p2 = [x; y];
pp = [p1 p2];
else
pp = [];
%error('exception', '%s', 'there exists exception');
end
return;
IT狂飙
- 粉丝: 4827
- 资源: 2653
最新资源
- 顺丰API查询快递单基于顺丰丰桥SDK开发的用易语言源码 免开发调用 需要收寄人手机号码后四位+单号查询 简单对接接口,快速开发必备 .zip
- 随着前端技术越来越成熟,JS,TS已成为各大厂开发的必备使用语言,本站从易到难深入理解JS,TS,同时提供TS做题功能,让你边学边实践,快速掌握.zip
- 通过中缀、后缀实现一个四则运算器,并设计求解界面,由于我喜欢前端嘛,用前端语言实现起来容易以及界面写起来很顺手 .zip
- 该项目是一个使用TypeScript实现的简易版Web系统框架,旨在提供一套搭建Web应用程序的基础设施 它具备以下主要特点和功能1. 虚拟文件系统2. 语言系统3. 常用接口集合.zip
- 网页编辑器,拖拽读取文件,保存文件,支持大部分编程语言文件编辑,简单易用,无需安装,这正是我想要的.zip
- 电力系统分析:基于VBA的分布式电源最佳接入点判定方法与程序实现
- MATLAB实现线性代数方程组直接解法算法解析与实践案例
- 基于MATLAB的线性代数方程组雅克比迭代解法研究与应用
- 基于MATLAB实现的线性代数方程组高斯消去法解析与应用
- MATLAB实现拉格朗日插值多项式的数值计算方法
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈