Code covered by the BSD License  

Highlights from
Line clipping

5.0

5.0 | 2 ratings Rate this file 5 Downloads (last 30 days) File Size: 1.53 KB File ID: #25528
image thumbnail

Line clipping

by Chandan

 

08 Oct 2009 (Updated 18 Feb 2010)

Line clipping by Cyrus Beck algorithm

| Watch this File

File Information
Description

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

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
15 Feb 2010 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.

17 Feb 2010 Richard Edmonds

Needs fixing, see comment.

18 Feb 2010 Chandan

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

01 Sep 2010 Richard Edmonds

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

Thanks.

Please login to add a comment or rating.
Updates
18 Feb 2010

Value of parameter "t" has been updated in line 18 and 19. I believe it was reverse in the order which earlier lead to the wrong results.

Tag Activity for this File
Tag Applied By Date/Time
line clipping Chandan 09 Oct 2009 11:11:19
cyrus beck clipping algorithm Chandan 09 Oct 2009 11:11:19
computer graphics Chandan 09 Oct 2009 11:11:19

Contact us at files@mathworks.com