由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - careercup书上一道题:判断直线相交
相关主题
CTCI上7.3题疑问F家题请教
Interview questions: points lie on same line两个链表怎么查找相交点?
吐槽g家package, 顺便说说昨天L家面经谁能给个小于n^3的算法
一道链表题及其变种bloomberg面试经历
MS bing onsite面经请问一道面试题
面试题请教一道有趣的算法题,请大侠点拨一下思路
f电面[Google] Arangement of blocks
求intersect的圆,求O(nlogn)的方法Benchmark: Oracle RDBMS vs Cassandra
相关话题的讨论汇总
话题: careercup话题: cartesian话题: 道题话题: slope话题: esp
进入JobHunting版参与讨论
1 (共1页)
k*j
发帖数: 153
1
careercup那本书上一道题。
10.3 Given two lines on a Cartesian plane, determine whether the two lines
would intersect.
书里是用slope来做。
return abs(line1.slope-line2.slope)>esp || abs(line1.yintercept - line2.
yintercept) < esp
但明显这没有考虑slope infinite的情况。所以不是很好的solution.
想问问这题有没有更general的解法呢?多谢!
s*****y
发帖数: 897
2
use expression
y = ax + b to represent a line then.
i***e
发帖数: 452
3
use cross product.
l*******r
发帖数: 511
4
更general的考虑radon transform跟hough transform吧

【在 k*j 的大作中提到】
: careercup那本书上一道题。
: 10.3 Given two lines on a Cartesian plane, determine whether the two lines
: would intersect.
: 书里是用slope来做。
: return abs(line1.slope-line2.slope)>esp || abs(line1.yintercept - line2.
: yintercept) < esp
: 但明显这没有考虑slope infinite的情况。所以不是很好的solution.
: 想问问这题有没有更general的解法呢?多谢!

k****n
发帖数: 369
5
in Cartesian plane, this is so far the best solution.
You may add specal case branching, but no major difference.

【在 k*j 的大作中提到】
: careercup那本书上一道题。
: 10.3 Given two lines on a Cartesian plane, determine whether the two lines
: would intersect.
: 书里是用slope来做。
: return abs(line1.slope-line2.slope)>esp || abs(line1.yintercept - line2.
: yintercept) < esp
: 但明显这没有考虑slope infinite的情况。所以不是很好的solution.
: 想问问这题有没有更general的解法呢?多谢!

l***i
发帖数: 1309
6
A1*x + B1*y + C1=0
A2*x + B2*y + C2=0
Solve a linear system.
need to check when det(A1,A2,B1,B2)=0
s*******1
发帖数: 3820
7
yintercept相等为什么就相交?
1 (共1页)
进入JobHunting版参与讨论
相关主题
Benchmark: Oracle RDBMS vs CassandraMS bing onsite面经
求关于数据库设计的资料面试题
请教个 interview questionf电面
问个题目,好像以前有人问过~~~求intersect的圆,求O(nlogn)的方法
CTCI上7.3题疑问F家题请教
Interview questions: points lie on same line两个链表怎么查找相交点?
吐槽g家package, 顺便说说昨天L家面经谁能给个小于n^3的算法
一道链表题及其变种bloomberg面试经历
相关话题的讨论汇总
话题: careercup话题: cartesian话题: 道题话题: slope话题: esp