0

Im stuck on the java script for line segment intersection.

If i have coordinates (a,b) and (c,d).....each a,b,c and d have each of their own (x,y) coordinates in array form. i.e a = (x[0], y[0]), b = (x[1], y[1]) and so on.

Now consider what happens if we move along one segment from one end to the other and then we turn to face each of the end points of the other segment

We observe that (a,b) meets (c,d) iff leftturn(a,b,c) xor leftturn(a,b,d) andleftturn(c,d,a) xorleftturn(c,d,b)

What would be the java code if the user was asked to input coordinates for each of the seperate line segments...and then check if a traversal such as (a,b,c) is a left or right turn and so on ?

Jas Pn
  • 31
  • 2
  • 5
  • 2
    Are you asking about Java or JavaScript? They're two totally different things. – BoltClock Nov 14 '11 at 12:33
  • Also, it seems as if this should be tagged "homework" as well. – ZenMaster Nov 14 '11 at 12:59
  • its just java sorry........this is a branch of what my final outcome is....ive just it a dead end at this point....would appreciate any help – Jas Pn Nov 15 '11 at 13:39
  • Welcome to StackOverflow! Show us what you've done so far, and try asking a more specific question. I doubt if people will be inclined to write the whole program for you, but they'll definitely give you a push in the right direction if you're stuck with something specific. Are you having trouble with Java or with the algorithm? Can you implement it in a different language? Is it homework? – Eli Acherkan Nov 15 '11 at 16:26
  • @ZenMaster Homework? There is only one answer here on SO that seems to deal with all corner cases. – AlexWien Nov 12 '14 at 17:31

0 Answers0