前置知识
在专题一中,我们主要谈到了向量之间关于长度的计算,那么在这里,我们将要谈到一些另外的运算方式。
弧度与角度的换算
1 deg = π 180 r a d , 1 r a d = 180 π deg 1\deg=\frac{\pi}{180}rad,1\space rad=\frac{180}{\pi}\deg 1deg=180πrad,1 rad=π180deg
两向量间夹角
定义:两个非零向量 a , b a,b a,b,它们间的夹角记为 < a , b > <a,b> <a,b>
由向量的点积公式知:
∣
X
∣
∣
Y
∣
c
o
s
(
γ
)
=
x
1
y
1
+
x
2
y
2
|X||Y|cos(\gamma)=x_1y_1+x_2y_2
∣X∣∣Y∣cos(γ)=x1y1+x2y2
所以
<
a
,
b
>
=
γ
=
a
c
o
s
(
X
⋅
Y
∣
X
∣
∣
Y
∣
)
=
a
c
o
s
(
x
1
y
1
+
x
2
y
2
∣
X
∣
×
∣
Y
∣
)
<a,b>=\gamma=acos(\frac{X\cdot Y}{|X||Y|})=acos(\frac{x_1y_1+x_2y_2}{|X|\times|Y|})
<a,b>=γ=acos(∣X∣∣Y∣X⋅Y)=acos(∣X∣×∣Y∣x1y1+x2y2)
我们从上述式子也可得出与
(
x
,
y
)
(x,y)
(x,y)垂直的一个向量为
(
y
,
−
x
)
(y,-x)
(y,−x)
代码如下:
double Dot(const Vector &p,const Vector &q){
return p.x*q.x+p.y*q.y;
}
double Length(const Vector &p){
return sqrt(Dot(p,p));
}
double Angle(const Vector &p,const Vector &q){
return acos(Dot(p,q)/Length(p)/Length(q));
}
a
,
b
,
c
a,b,c
a,b,c为
∠
A
,
∠
B
,
∠
C
\angle A,\angle B,\angle C
∠A,∠B,∠C 的对边,
R
R
R为
Δ
A
B
C
\Delta ABC
ΔABC的外接圆半径
正弦定理
a s i n A = b s i n B = c s i n C = 2 R \frac{a}{sinA}=\frac{b}{sinB}=\frac{c}{sinC}=2R sinAa=sinBb=sinCc=2R
余弦定理
a
2
=
b
2
+
c
2
−
2
b
c
cos
A
a^2=b^2+c^2-2bc\cos A
a2=b2+c2−2bccosA
b
2
=
a
2
+
c
2
−
2
a
c
cos
B
b^2=a^2+c^2-2ac\cos B
b2=a2+c2−2accosB
c
2
=
a
2
+
b
2
−
2
a
b
cos
C
c^2=a^2+b^2-2ab\cos C
c2=a2+b2−2abcosC
向量的旋转
设
∣
a
⃗
∣
=
L
|\vec a|=L
∣a∣=L,那么我们有
x
=
L
∗
c
o
s
β
,
y
=
L
∗
s
i
n
β
x=L*cos\beta,y=L*sin\beta
x=L∗cosβ,y=L∗sinβ
c
o
s
(
β
+
θ
)
=
c
o
s
β
c
o
s
θ
−
s
i
n
β
s
i
n
θ
cos(\beta+\theta)=cos\beta cos\theta-sin\beta sin\theta
cos(β+θ)=cosβcosθ−sinβsinθ
s
i
n
(
β
+
θ
)
=
s
i
n
β
c
o
s
θ
+
c
o
s
β
s
i
n
θ
sin(\beta+\theta)=sin\beta cos\theta+cos\beta sin\theta
sin(β+θ)=sinβcosθ+cosβsinθ
x
′
=
L
∗
c
o
s
(
β
+
θ
)
=
x
c
o
s
θ
−
y
s
i
n
θ
x'=L*cos(\beta+\theta)=xcos\theta-ysin\theta
x′=L∗cos(β+θ)=xcosθ−ysinθ
y
′
=
L
∗
s
i
n
(
β
+
θ
)
=
y
c
o
s
θ
+
x
s
i
n
θ
y'=L*sin(\beta+\theta)=ycos\theta+xsin\theta
y′=L∗sin(β+θ)=ycosθ+xsinθ