Abstract

This chapter discusses intersection of line segments. A problem is presented in which for given two line segments in two dimensional (2D) space, it is to be determined whether they intersect or not. If they intersect, then the point of intersection is also determined. The chapter presents an algorithm which is particularly efficient if the lines often do not, in fact, intersect. It highlights that the algorithm will work in floating point coordinates; but if all xi and yi are available as integers (as is usually the case in bitmap graphics) and the result is required on an integer grid, only integer arithmetic is required. However, for integer-only arithmetic, care should be taken to guard against the possibility of overflow. The polynomial evaluations in the C implementation are at most of degree 3; therefore, using 32-bit integers, a range of 0–1023 in both X and Y directions can be handled. For larger ranges, floating point operations may be necessary, or a rearrangement of the intersection-point computations may be necessary.

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.