結果
| 問題 | No.622 点と三角柱の内外判定 | 
| コンテスト | |
| ユーザー |  wajima_wataru | 
| 提出日時 | 2017-12-29 18:27:27 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 39 ms / 1,500 ms | 
| コード長 | 1,558 bytes | 
| コンパイル時間 | 233 ms | 
| コンパイル使用メモリ | 12,928 KB | 
| 実行使用メモリ | 11,264 KB | 
| 最終ジャッジ日時 | 2024-12-21 10:34:15 | 
| 合計ジャッジ時間 | 2,573 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 32 | 
ソースコード
from math import sin, cos, atan2
from operator import *
pos = []
for _ in range(4):
	pos.append(list(map(float, input().split())))
def rotate_x(p, theta):
	q = []
	q.append(p[0])
	q.append(p[1] * cos(theta) - p[2] * sin(theta))
	q.append(p[1] * sin(theta) + p[2] * cos(theta))
	return q
def rotate_y(p, theta):
	q = []
	q.append(p[2] * sin(theta) + p[0] * cos(theta))
	q.append(p[1])
	q.append(p[2] * cos(theta) - p[0] * sin(theta))
	return q
def rotate_z(p, theta):
	q = []
	q.append(p[0] * cos(theta) - p[1] * sin(theta))
	q.append(p[0] * sin(theta) + p[1] * cos(theta))
	q.append(p[2])
	return q
def translate(p, q):
	for i in range(3):
		p[i] += q[i]
	return p
d = list(map(neg, pos[0]))
for i in range(4):
	pos[i] = translate(pos[i], d)
th1 = atan2(pos[1][2], pos[1][0])
for i in range(4):
	pos[i] = rotate_y(pos[i], th1)
th2 = atan2(-pos[1][1], pos[1][0])
for i in range(4):
	pos[i] = rotate_z(pos[i], th2)
th3 = atan2(-pos[2][2], pos[2][1])
for i in range(4):
	pos[i] = rotate_x(pos[i], th3)
AD = [pos[3][0] - pos[0][0], pos[3][1] - pos[0][1]]
BD = [pos[3][0] - pos[1][0], pos[3][1] - pos[1][1]]
CD = [pos[3][0] - pos[2][0], pos[3][1] - pos[2][1]]
AB = [pos[1][0] - pos[0][0], pos[1][1] - pos[0][1]]
BC = [pos[2][0] - pos[1][0], pos[2][1] - pos[1][1]]
CA = [pos[0][0] - pos[2][0], pos[0][1] - pos[2][1]]
def cross(a, b):
	return a[0] * b[1] - b[0] * a[1]
if cross(AB, BD) > 0 and cross(BC, CD) > 0 and cross(CA, AD) > 0:
	print('YES')
elif cross(AB, BD) < 0 and cross(BC, CD) < 0 and cross(CA, AD) < 0:
	print('YES')
else:
	print('NO')
            
            
            
        