l*c
2 楼
前两周去onsite面的一家公司,其中一道题是(签了disclosure,不好全发出来)
1. How to represent a rectangle in a 2D plane? The rectangle can be rotated
by any angle.
2. How to determine if two given rectangle overlap with each other?
大概说思路+写代码用了半个小时,回来稍微整理了一下,下面是地址
http://blog.theliuy.com/determine-if-two-rotated-rectangles-ove
应该还有更好的办法,当时也只能想出来这么多了。。。
估计下周出结果,求bless,本人新手还不知道包子怎么给(也不知道自己有没有)…
…
1. How to represent a rectangle in a 2D plane? The rectangle can be rotated
by any angle.
2. How to determine if two given rectangle overlap with each other?
大概说思路+写代码用了半个小时,回来稍微整理了一下,下面是地址
http://blog.theliuy.com/determine-if-two-rotated-rectangles-ove
应该还有更好的办法,当时也只能想出来这么多了。。。
估计下周出结果,求bless,本人新手还不知道包子怎么给(也不知道自己有没有)…
…
f*s
4 楼
graphics的背景?
rotated
【在 l*****c 的大作中提到】
: 前两周去onsite面的一家公司,其中一道题是(签了disclosure,不好全发出来)
: 1. How to represent a rectangle in a 2D plane? The rectangle can be rotated
: by any angle.
: 2. How to determine if two given rectangle overlap with each other?
: 大概说思路+写代码用了半个小时,回来稍微整理了一下,下面是地址
: http://blog.theliuy.com/determine-if-two-rotated-rectangles-ove
: 应该还有更好的办法,当时也只能想出来这么多了。。。
: 估计下周出结果,求bless,本人新手还不知道包子怎么给(也不知道自己有没有)…
: …
rotated
【在 l*****c 的大作中提到】
: 前两周去onsite面的一家公司,其中一道题是(签了disclosure,不好全发出来)
: 1. How to represent a rectangle in a 2D plane? The rectangle can be rotated
: by any angle.
: 2. How to determine if two given rectangle overlap with each other?
: 大概说思路+写代码用了半个小时,回来稍微整理了一下,下面是地址
: http://blog.theliuy.com/determine-if-two-rotated-rectangles-ove
: 应该还有更好的办法,当时也只能想出来这么多了。。。
: 估计下周出结果,求bless,本人新手还不知道包子怎么给(也不知道自己有没有)…
: …
D*9
9 楼
i am si dao
c*p
10 楼
mark
r*n
11 楼
"While, if the given rectangles are rotated by any angle, my solution is to
check the corners of each rectangle. If one of them is inside of another
rectangle, these two rectangles overlap. Otherwise, they are not."
不对吧,比如两个长方形组成十字架的形状,虽然没有任何一个角落在另外一个长方形
里面,但是这两个长方形仍然相交。
我觉得判定不相交比判定相交容易些:
求出长方形A的四条边的直线方程,这四条边组成两组平行线
用长方形B的四个角和A的两组平行线比较,如果存在一组平行线使得B的四个角都在其
同一侧(带入直线方程,符号一样),那么不相交。
否则互换A,B,然后再测试一下。
如果两次测试其中任何一次是“不相交”,那么A,B就不相交,否则A,B相交。
rotated
【在 l*****c 的大作中提到】
: 前两周去onsite面的一家公司,其中一道题是(签了disclosure,不好全发出来)
: 1. How to represent a rectangle in a 2D plane? The rectangle can be rotated
: by any angle.
: 2. How to determine if two given rectangle overlap with each other?
: 大概说思路+写代码用了半个小时,回来稍微整理了一下,下面是地址
: http://blog.theliuy.com/determine-if-two-rotated-rectangles-ove
: 应该还有更好的办法,当时也只能想出来这么多了。。。
: 估计下周出结果,求bless,本人新手还不知道包子怎么给(也不知道自己有没有)…
: …
check the corners of each rectangle. If one of them is inside of another
rectangle, these two rectangles overlap. Otherwise, they are not."
不对吧,比如两个长方形组成十字架的形状,虽然没有任何一个角落在另外一个长方形
里面,但是这两个长方形仍然相交。
我觉得判定不相交比判定相交容易些:
求出长方形A的四条边的直线方程,这四条边组成两组平行线
用长方形B的四个角和A的两组平行线比较,如果存在一组平行线使得B的四个角都在其
同一侧(带入直线方程,符号一样),那么不相交。
否则互换A,B,然后再测试一下。
如果两次测试其中任何一次是“不相交”,那么A,B就不相交,否则A,B相交。
rotated
【在 l*****c 的大作中提到】
: 前两周去onsite面的一家公司,其中一道题是(签了disclosure,不好全发出来)
: 1. How to represent a rectangle in a 2D plane? The rectangle can be rotated
: by any angle.
: 2. How to determine if two given rectangle overlap with each other?
: 大概说思路+写代码用了半个小时,回来稍微整理了一下,下面是地址
: http://blog.theliuy.com/determine-if-two-rotated-rectangles-ove
: 应该还有更好的办法,当时也只能想出来这么多了。。。
: 估计下周出结果,求bless,本人新手还不知道包子怎么给(也不知道自己有没有)…
: …
l*c
12 楼
哦对 忘了这个情况了……
to
【在 r*********n 的大作中提到】
: "While, if the given rectangles are rotated by any angle, my solution is to
: check the corners of each rectangle. If one of them is inside of another
: rectangle, these two rectangles overlap. Otherwise, they are not."
: 不对吧,比如两个长方形组成十字架的形状,虽然没有任何一个角落在另外一个长方形
: 里面,但是这两个长方形仍然相交。
: 我觉得判定不相交比判定相交容易些:
: 求出长方形A的四条边的直线方程,这四条边组成两组平行线
: 用长方形B的四个角和A的两组平行线比较,如果存在一组平行线使得B的四个角都在其
: 同一侧(带入直线方程,符号一样),那么不相交。
: 否则互换A,B,然后再测试一下。
to
【在 r*********n 的大作中提到】
: "While, if the given rectangles are rotated by any angle, my solution is to
: check the corners of each rectangle. If one of them is inside of another
: rectangle, these two rectangles overlap. Otherwise, they are not."
: 不对吧,比如两个长方形组成十字架的形状,虽然没有任何一个角落在另外一个长方形
: 里面,但是这两个长方形仍然相交。
: 我觉得判定不相交比判定相交容易些:
: 求出长方形A的四条边的直线方程,这四条边组成两组平行线
: 用长方形B的四个角和A的两组平行线比较,如果存在一组平行线使得B的四个角都在其
: 同一侧(带入直线方程,符号一样),那么不相交。
: 否则互换A,B,然后再测试一下。
f*y
13 楼
本人非码工,随便扯两句。
是我的话长方形的表示是一个中心点,任意两个相邻顶点。根据这个能求出长方形四条
边方程。如果两个长方形有重合那要么是边有相交(求线段交点是否在线段内),要么
是一个长方型完全被包在另一个内部。可以通过看中心点是否在另一个长方形内来判断
(检查定点到中心点距离小的那个长方形)。
是我的话长方形的表示是一个中心点,任意两个相邻顶点。根据这个能求出长方形四条
边方程。如果两个长方形有重合那要么是边有相交(求线段交点是否在线段内),要么
是一个长方型完全被包在另一个内部。可以通过看中心点是否在另一个长方形内来判断
(检查定点到中心点距离小的那个长方形)。
c*o
15 楼
看矩形a中的顶点是否在矩形b内
g*G
16 楼
EPI原题嘛
相关阅读
拿了OFFER又有新的面试公司给工资是hr定的还是hiringmanager定的?Life Technologies 这个公司怎么样?还是要当quant!做题更有压力了LCA 今天还没file,是不是不赶趟了,求bless亚麻的software engineer in test 和software engineer in development package一样么统计类的工作去federal 安全末? (转载)面试时H1b的gap怎么说比较好?OPT extension[2个包子]cpt刚approve后能立即申请opt么L家onsite悲剧 贡献个面经吧初申绿卡,真心求助!请问公司招CPT的门槛,会不会比OPT或正式员工低一些问下professional references (for after the interview)没有咋办?问个题 weighted random sampling现在申OPT 请问多久能批下来问个关于H1b transfer的问题雇主第一次给员工办理H1b,LCA过程需要额外多五天?求助,关于和公司谈工资