ganesh_6's blog

By ganesh_6, history, 3 years ago, In English

I was solving the question http://mirror.codeforces.com/contest/227/problem/A. If the cross product is zero then obviously they are collinear since sin(x)=0 if x=2*n*PI. However, how do they decide if it is Left or Right based on the value of cross-product i.e; x1*y2-x2*y1. Please demystify this for me. Am I missing any fundamentals?

C++
  • Vote: I like it
  • +3
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Function cp calculates the z-coordinate of the cross product. Then you can use the right hand rule to determine the direction (angle CAB is always less than 90) If C is to the left => Thumb will go down => z-coordinate less than 0 => t is less than 0, and vice versa

  • »
    »
    3 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Awesome! Now I remember my school days. These are the stuff I learned in my school in Physics and maths. Looks like I need to revise a lot in the process. Thanks a ton!