×

Loading...
Ad by
  • 予人玫瑰,手有余香:加拿大新天地工作移民诚聘求职顾问&行业导师!
Ad by
  • 予人玫瑰,手有余香:加拿大新天地工作移民诚聘求职顾问&行业导师!

平面几何的东西吧。

今天好像很闲阿。作题拉:
circle:
A(x1,y1)
B(x2,y2)
C(x3,y3 )

first get the vertical equal-split line of line AB:
ponit1 D( (x1+x2)/2, (y1+y2)/2 )
point2 E( (x1+x2)/2 - (y2 - (y1+y2)/2), (y1+y2)/2 - ( x2-(x1+x2)/2) )

same way, get the vertical equal-split line of line BC:
F
G

Now we need to find the join point of Line DE and Line FG.

general argrithum for join point of two lines:
D(xd,yd) E(xe,ye) ( xe> xd)
F(xf,yf) G(xg,yg) ( xg>xf )

Jion point J: ( xj,yj) should be
(xj-xd)/(xe-xd) = ( yj-yd)/(ye-yd)
(xj-xf)/(xg-xf) = ( yj-yf)/(yg-yf)

Then we can get xj and yj.

This join point is the center of this circle.
Then we can get the R of this circle.

For the other line O(xo,yo)P(xp,yp), need to create a vertical line with OP, and go through J, then caculate the join point Q, and find the length of JQ
caculate the length of JQ, if it's less than R, they are joined.
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 本人编程急需一个判断线段(line segment)和弧(arc)是否相交并计算出交点坐标(可以是1个或者2个)的算法,查阅了google和两本算法书都找不到相关算法,恳请专家们指导。
    • 怎么听着好像是你老本行的东西。
      • 唉,俺是学电子的,数学是个弱项。这些算法们都是拿来能用就行。通用的俺都有算法函数库,可是只有直线和弧相交的部分,找不到线段和弧的相关算法。
        • 如果知道相交,那应该能得到交点吧?知道交点坐标,那不就能知道是不是在线段上了?
          • 就是需要算法首先判断是否相交,如果相交再进一步给出交点坐标。 当然有的算法可能判断和给出交点坐标是同时得到的。都可以啊
            • 我不知道你在写什么程序.不过,你那段弧,总有个涵数吧?线段,也有一个吧?这两有了,总能解决的么.:D
              • 已知参数: 弧的三个坐标 startPt, endPt, centerPt, line segment的两个坐标pt0,pt1,就是想找个最好是直接的数学算法,否则还要进行头疼的象限、角度等的逐步排除比较,这种最容易出bug了
                • 是圆弧?椭圆?抛物线?
                  • sorry, 没说清除。 圆弧,否则参数不会这么简单 : )
                    • 看来你解析几何是忘光了,这个也要看算法书?自己推个公式出来应该就可以了吧。
        • 如果你有直线和弧相交的算法,线段和弧的相关算法不是就在里面吗? 直线和弧不交,线段也不交。直线和弧交,判断交点是否在线段上。
          • 刚才细看了一下,原来看错了,直线和弧的算法也没有 :-(
            • 那就先找直线和弧的算法,应该很多的。:)
              • 好的思路,谢谢。
            • 再怎么整,也就是个二元二次方程么
              1) Y= AX+B
              2) aY^2+bY+c = dX^2+ex

              然后把1)代进2),弄到一个一元二次方程,求根公式一捣腾,不就出来了?
    • 三天不学习,你就。。。
    • arc 的公式?
    • 平面几何的东西吧。
      今天好像很闲阿。作题拉:
      circle:
      A(x1,y1)
      B(x2,y2)
      C(x3,y3 )

      first get the vertical equal-split line of line AB:
      ponit1 D( (x1+x2)/2, (y1+y2)/2 )
      point2 E( (x1+x2)/2 - (y2 - (y1+y2)/2), (y1+y2)/2 - ( x2-(x1+x2)/2) )

      same way, get the vertical equal-split line of line BC:
      F
      G

      Now we need to find the join point of Line DE and Line FG.

      general argrithum for join point of two lines:
      D(xd,yd) E(xe,ye) ( xe> xd)
      F(xf,yf) G(xg,yg) ( xg>xf )

      Jion point J: ( xj,yj) should be
      (xj-xd)/(xe-xd) = ( yj-yd)/(ye-yd)
      (xj-xf)/(xg-xf) = ( yj-yf)/(yg-yf)

      Then we can get xj and yj.

      This join point is the center of this circle.
      Then we can get the R of this circle.

      For the other line O(xo,yo)P(xp,yp), need to create a vertical line with OP, and go through J, then caculate the join point Q, and find the length of JQ
      caculate the length of JQ, if it's less than R, they are joined.
      • 还有些小问题。求两直线交点时需判断 xe!=xd, ye!=yd..., 如果是则 xj=xe...