Convex hull
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (1)
Jan
il 10 Mar 2011
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:
0 Commenti
Vedere anche
Categorie
Scopri di più su Bounding Regions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!