background preloader

Algorithms coding

Facebook Twitter

Practice Problems: Dashboard. Algorithm Tutorials. Geometry Concepts: Line Intersection and its Applications By lbackstromTopCoder Member ...read Section 1 Line-Line IntersectionFinding a Circle From 3 PointsReflectionRotationConvex Hull In the previous section we saw how to use vectors to solve geometry problems. Now we are going to learn how to use some basic linear algebra to do line intersection, and then apply line intersection to a couple of other problems. Line-Line Intersection One of the most common tasks you will find in geometry problems is line intersection. Despite the fact that it is so common, a lot of coders still have trouble with it. Double det = A1*B2 - A2*B1 if(det == 0){ //Lines are parallel }else{ double x = (B2*C1 - B1*C2)/det double y = (A1*C2 - A2*C1)/det } To see where this comes from, consider multiplying the top equation by B2, and the bottom equation by B1.

This gives you the location of the intersection of two lines, but what if you have line segments, not lines. ...continue to Section 3. Technical reports : dr. H.L. Bodlaender. Theory of Computation. CS Theory @ Princeton : Draft browse.