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.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
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
q
x
s, q
x
r
, and
r
x
s
Compute auxiliary values:
q
*
r
,
r
*
r
,
q
*
s
, and
s
*
s
If
r
x
s
is zero and
q
x
r
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
r
x
s
is zero and
q
x
r
is not zero
The two lines are parallel and not intersecting
If
r
x
s
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
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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?
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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.
...