File Exchange

image thumbnail

Line clipping

version 1.1.0.0 (1.53 KB) by Chandan Kumar
Line clipping by Cyrus Beck algorithm

2 Downloads

Updated 18 Feb 2010

View Version History

View License

Clips a line inside a view port according to Cyrus beck algorithm.

Cite As

Chandan Kumar (2021). Line clipping (https://www.mathworks.com/matlabcentral/fileexchange/25528-line-clipping), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Sheytra balan

Richard Edmonds

Good stuff, all working. It's also been a nice basis for the development of a 3D cyrus-beck lineclipping function.

Thanks.

Chandan Kumar

Thank you, Mr. Edmonds it seems you were right about the origin of error. I took the liberty to make changes in the code.

Richard Edmonds

Needs fixing, see comment.

Richard Edmonds

There appears to be a mistake in this code, sorry. Its quite clear if the following data is entered at the prompt:
[0 0.1 1 1.9]
[0.2 0.2 0.8 0.8]
I suggest its related to the max/min lines. I suggest that you evaluate which t are valid for entering the view port and then eveluate which is the max entering t and min entering t from each set of valid t for each. Also parallel lines should be checked too or risk div0.

MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!