Length of cross of segment and rectangle

If segment is outside rectangle then return 0
340 Downloads
Updated 10 Jan 2011

View License

http://simulations.narod.ru/

segment_rectange.m is the function that difine length of cross.

cross_perimeter.m auxillary function for segment_rectange.m, it define points of cross of segment and perimeter of rectangle

zz_segment_rectange_test.m is script-test, it tests segment_rectange.m by use random segments plot it and print length near segment.

Usage of segment_rectange.m:
L=segment_rectange(a,b,r)
rectange a x b
rectangle is 0<=x<=a 0<=y<=b
segment between r(:,1) and r(:,2)

Cite As

Maxim Vedenyov (2024). Length of cross of segment and rectangle (https://www.mathworks.com/matlabcentral/fileexchange/29988-length-of-cross-of-segment-and-rectangle), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009a
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!
Version Published Release Notes
1.1.0.0

Some errors fixed, more complex test in zz_segment_rectange_test.m

1.0.0.0