Convex hull

3 ビュー (過去 30 日間)
Raghuram
Raghuram 2011 年 3 月 10 日
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
Jan 2011 年 3 月 10 日
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:

カテゴリ

Help Center および File ExchangeBounding Regions についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by