Pergunta de entrevista da empresa Edifecs

Given four (x,y) coordinate pairs, two coordinates that represent one line segment and two coordinates that represent another line segment, determine if those line segments intersect...

Resposta da entrevista

Sigiloso

13 de set. de 2017

I found the slope of both line segments, wrote both line segments in slope intercept form, checked if slopes are equal. If they were equal, return false b/c the line segments will either be parallel or overlapping, but not intersecting. Otherwise, I solved for x and y mathematically (assuming I had two infinite lines of those slop intercept forms), and then determined if that (x,y) coordinate is within the range of both line segments...

1