由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 一道编程题 晕
相关主题
这个facebook puzzle样题怎么做?亚马逊 面经
FB coding challenge sample question问道题
汉诺塔为啥dfs可以解决?问个面试题
被烙印阴了: draw a line across two pointsM家面试题:write a function to draw a circle
求算法经典activity selection的问题
一道面试碰到的概率题问一道精华帖的老题
一道面试题问个简单的数学编程题吧(google interview)
问一道某网站上看到的题目,求递增的三元组programming pearl看不懂这个题
相关话题的讨论汇总
话题: p1话题: p2话题: circle话题: radius话题: triangle
进入JobHunting版参与讨论
1 (共1页)
b****r
发帖数: 1272
1
In 3D, 给定P1,P2坐标,和两个相连线段,长度分别为L1,L2,已知其中一个线段头在P1点。现在要
把另外那个线段的尾放在P2点,要求写一个FUNCTION返回这两个线段的向量表达式。
交点的通解应该在一个圆上。题目说,至少给定一组有效解。3D编程大牛给讲讲,谢了。
L****t
发帖数: 924
2
p1+v_1L1 + v_2L2 = p2 ?

P1点。现在要
了。

【在 b****r 的大作中提到】
: In 3D, 给定P1,P2坐标,和两个相连线段,长度分别为L1,L2,已知其中一个线段头在P1点。现在要
: 把另外那个线段的尾放在P2点,要求写一个FUNCTION返回这两个线段的向量表达式。
: 交点的通解应该在一个圆上。题目说,至少给定一组有效解。3D编程大牛给讲讲,谢了。

c*****o
发帖数: 178
3
是不是以P2为圆心,L2为半径的一个圆球和以P1为园心,L1为半径的一个圆球的交集啊
,是一个圆。
c**********e
发帖数: 2007
4

Yes.
If P is any point on 萧十一姐's circle, then we have
|P-P1| = l_1, or |P-P1|^2 = l_1^2. ... ... (1)
|P-P2| = l_2, or |P-P2|^2 = l_2^2. ... ... (2)
The difference of the two is
(P2-P1)*(2P-P1-P2)=l_1^2-l_2^2. ... ... (3)
The circle is in the plane (3).

【在 c*****o 的大作中提到】
: 是不是以P2为圆心,L2为半径的一个圆球和以P1为园心,L1为半径的一个圆球的交集啊
: ,是一个圆。

c**********e
发帖数: 2007
5
For programming purpose, let us decide the circle's center C,
radius r, and radius vector.
Look at the triangle PP_1P_2, where P is any point on the target
circle. The 3sides are
a = l_1
b = l_2
c = |P_1-P_2|, where |.| means distance
denote s=(a+b+c)/2.
Then the area of triangle: ea=sqrt(s*(s-a)*(s-b)*(s-c)).
The height of the triangle is the radius of the circle:
r = h = 2*area/c
The distance d=|P_1-O|=sqrt(l_1^2-r^2).
So C = P_1 + P_1 + d*(P_2-P_1)/|P_2-P_1|
So P = C + r*v1 where v is any uni
1 (共1页)
进入JobHunting版参与讨论
相关主题
programming pearl看不懂这个题求算法
问个问题一道面试碰到的概率题
Google Onsite Interview一道面试题
问道题,看不太懂问一道某网站上看到的题目,求递增的三元组
这个facebook puzzle样题怎么做?亚马逊 面经
FB coding challenge sample question问道题
汉诺塔为啥dfs可以解决?问个面试题
被烙印阴了: draw a line across two pointsM家面试题:write a function to draw a circle
相关话题的讨论汇总
话题: p1话题: p2话题: circle话题: radius话题: triangle