Beta

Line Crossing Area

Description:

Line Crossing Area

In this Kata you should write a function that checks if a line segment is crossing or inside a rectangular area. The line segment is created by the (x,y) coordinates of two given points (p0,p1) and the rectangle (r) is created by the (x,y) coordinates of its center and width and height values. The function should return True if the line segment instersects the area and False otherwise.

image

The input is given by 2 parameters, parameter rectangle which is passed as a tuple in the format (r_x, r_y, r_width, r_height). And the parameter line which is passed as a tuple of tuples in the format ((p0_x, p0_y),(p1_x, p1_y)), the first tuple contains the (x,y) coordinates for point 0 (p0) and the second tuple contains the (x,y) coordinates for point 1 (p1).

Note

A line segment touching one of the rectangle vertices should return True.

Geometry
Puzzles

More By Author:

Check out these other kata created by lfhohmann

Stats:

CreatedMay 22, 2021
PublishedMay 23, 2021
Warriors Trained49
Total Skips0
Total Code Submissions265
Total Times Completed19
Python Completions19
Total Stars2
% of votes with a positive feedback rating91% of 11
Total "Very Satisfied" Votes10
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes1
Total Rank Assessments11
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • lfhohmann Avatar
Ad