Convex hull
显示 更早的评论
Hello, I have two vectors, x, and y:
x = [0.3333 0.5000 0.6667 0.7000]
x =
0.3333 0.5000 0.6667 0.7000
>> y = [0.6667 0.5000 0.3333 0.7000]
y =
0.6667 0.5000 0.3333 0.7000
>> convhull(x,y)
ans =
1
3
4
1
>> I know that (0.5 0.5) should theoretically be in the hull. If I try this, it works: x = single(x)
x =
0.3333 0.5000 0.6667 0.7000
>> y = single(y)
y =
0.6667 0.5000 0.3333 0.7000
>> x = double(x)
x =
0.3333 0.5000 0.6667 0.7000
>> y = double(y)
y =
0.6667 0.5000 0.3333 0.7000
>> convhull(x,y)
ans =
1
2
3
4
1
Now notice point 2 appears. So two questions: 1) Why does switching to single and coming back to double work? 2) Why does (0.5,0.5) not appear initially as part of the hull? Thank you, Raghu
回答(1 个)
Jan
2011-3-10
3 个投票
The point (0.5, 0.5) is almost an element of the edge. Rounding to SINGLE and increasing the precision back to DOUBLE can move all points a little bit. Remember that 0.6667 is not 2*0.3333 and that floating point numbers in decimal notation do not have necessarily an exactly equal representation in binary notation, which are used for computations.
See also:
类别
在 帮助中心 和 File Exchange 中查找有关 Bounding Regions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!