1. 自然语言
二维向量叉乘:(x1,y1)×(x2,y2) = x1y2-x2y1值的绝对值是两向量同起点,构成平行四边形的面积值为正,(x2,y2)在(x1,y1)逆时针方向值为负,(x2,y2)在(x1,y1)顺时针方向值为0,(x2,y2)和(x1,y1)共线
2.编程语言
from pylab
import *
x
=[-3, -2, -1, 2, 4]
y
=[-3, 1, -1, 0, 3]
plt
.axis
("equal")
plt
.plot
(x
, y
, 'ro-', color
='#4169E1', alpha
=0.8, linewidth
=1, label
='example')
plt
.legend
(loc
="upper right")
plt
.xlabel
('x')
plt
.ylabel
('y')
for i
in range(3):
tx
= x
[i
]-x
[i
+1]
ty
= y
[i
]-y
[i
+1]
xx
= x
[i
+2]-x
[i
+1]
yy
= y
[i
+2]-y
[i
+1]
print tx
,ty
,xx
,yy
,tx
*yy
-ty
*xx
程序中5点4线如下图输出:
-1 -4 1 -2 6 -1 2 3 1 -7 -3 -1 2 3 -7