Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how to write this algorthim in c++ plz its important

+1 vote
asked Feb 3, 2019 by anonymous 1 flag

Algorithm

  • Read x1, y1, x2, y2
  • Read x3, y3, x4, y4
  • Compute vectors r, s, and q
  • Compute cross-products qxs, qxr, and rxs
  • Compute auxiliary values: q*r, r*r, q*s, and s*s
  • If rxs is zero and qxr is zero, then
    • The two lines are collinear
      • If 0 <= q*r <= r*r or 0 <= q*s <= s*s
        • The two lines are overlapping
      • else
        • The two lines are disjoint
  • If rxs is zero and qxr is not zero
    • The two lines are parallel and not intersecting
  • If rxs is not zero , compute t and u
    • If   0 <= t <= 1 and 0 <= u <= 1
      • The two lines intersect at (x1)
    • else
      • The two line segments do not intersect

1 Answer

0 votes
answered Feb 26, 2019 by anonymous
What does "compute vectors r, s and q" mean?  Compute is a fairly generic word.  Can you explain how

to computer the vectors?
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...