Convex hull
조회 수: 10 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Bounding Regions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!