官术网_书友最值得收藏!

29. Line-line intersection

Write a program that determines where two lines intersect. Let the user left-click twice to define one line and right-click twice to define another. Be sure that the program can handle horizontal and vertical lines, and the case when the lines are parallel.

Hint: Use a parametric definition for the lines as in p = p0 + t × v where p0 is a point on the line, v is a vector pointing in the direction of the line, and t is a real number parameter. If that doesn't make sense to you, then read the solution. You may want to stop after the explanation and try to implement the code yourself before you read the entire solution.
主站蜘蛛池模板: 密云县| 延吉市| 翁牛特旗| 元朗区| 噶尔县| 安阳县| 大洼县| 双峰县| 靖州| 岳阳市| 扎鲁特旗| 海南省| 九台市| 龙胜| 新源县| 安福县| 曲水县| 大洼县| 怀宁县| 兴宁市| 宝鸡市| 孟村| 句容市| 涞水县| 都昌县| 龙口市| 都昌县| 霍邱县| 扬中市| 阿拉善盟| 柏乡县| 乌拉特前旗| 东平县| 宝山区| 庐江县| 利津县| 武隆县| 墨脱县| 南开区| 班戈县| 辰溪县|