LoginSignup
1
0

More than 5 years have passed since last update.

Parallel and orthogonal judgement with dot and cross from input for two four points

Last updated at Posted at 2018-04-04
n = input
a = []
for i in range(n):
  a.append(map(int, raw_input().split()))
for aa in a:
  an = np.array(aa).reshape(4,2)
  s1 = an[1]-an[0]
  s2 = an[3]-an[2]
  dot = np.dot(s1,s2)
  cross = np.cross(s1,s2)
  if (dot==0):
    print("1")
  elif (cross==0):
    print("2")
  else:
    print("0")
3
0 0 3 0 0 2 3 2
0 0 3 0 1 1 1 4
0 0 3 0 1 1 2 2
2
1
0

Refs.

http://d.hatena.ne.jp/pashango_p/20090714/1247590272
https://qiita.com/lethe2211/items/6cbade2bc547649bc040

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0