3D Bresenham's line generation

버전 1.0.0.0 (2.69 KB) 작성자: Jimmy Shen
Generate X Y Z coordinates of a 3D Bresenham's line between two given points
다운로드 수: 3.4K
업데이트 날짜: 2008/8/22

라이선스 보기

This program will generate the coordinates of a 3D Bresenham's raster line between two given points.

A very useful application of this algorithm can be found in the implementation of Fischer's Bresenham interpolation method in my another program that can rotate three dimensional image volume with an affine matrix:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=21080

Usage: [X Y Z] = bresenham_line3d(P1, P2);

P1 - vector for Point1, where P1 = [x1 y1 z1]

P2 - vector for Point2, where P2 = [x2 y2 z2]

precision (optional) - Although according to Bresenham's line algorithm, point coordinates x1 y1 z1 and x2 y2 z2 should be integer numbers, this program extends its limit to all real numbers. If any of them are floating numbers, you should specify how many digits of decimal that you would like to preserve. Be aware that the length of output X Y Z coordinates will increase in 10 times for each decimal digit that you want to preserve. By default, the precision is 0, which means that they will be rounded to the nearest integer.

X - a set of x coordinates on Bresenham's line

Y - a set of y coordinates on Bresenham's line

Z - a set of z coordinates on Bresenham's line

Therefore, all points in XYZ set (i.e. P(i) = [X(i) Y(i) Z(i)]) will constitute the Bresenham's line between P1 and P1.

Example:

P1 = [12 37 6]; P2 = [46 3 35];
[X Y Z] = bresenham_line3d(P1, P2);
figure; plot3(X,Y,Z,'s','markerface','b');

This program is ported to MATLAB from:

B.Pendleton. line3d - 3D Bresenham's (a 3D line drawing algorithm), 1992.
ftp://ftp.isc.org/pub/usenet/comp.sources.unix/volume26/line3d

Which is also referenced by:

Fischer, J., A. del Rio (2004). A Fast Method for Applying Rigid Transformations to Volume Data, WSCG2004 Conference.
http://wscg.zcu.cz/wscg2004/Papers_2004_Short/M19.pdf

인용 양식

Jimmy Shen (2024). 3D Bresenham's line generation (https://www.mathworks.com/matlabcentral/fileexchange/21057-3d-bresenham-s-line-generation), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R10
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Spectrum and Signal Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0

Real numbers can now be used, since you can specify how many digits of decimal you want to preserve. Be aware that length of output coordinate will increase in 10 times for each digit. It is 0 by default, means everything will be rounded to integer.