The Law of Cosines in 3D

The Law of Cosines is a fundamental trigonometric formula that relates the lengths of the sides of a triangle to the cosine of one of its angles. This formula has a 3D version, which is very useful in solving problems related to three-dimensional geometry.

In a 3D space, a triangle is formed by connecting three points in space, which are the vertices of the triangle. These points can be represented by their position vectors, a\vec{a}, b\vec{b} and c\vec{c}. The sides of the triangle are formed by the vectors that connect the vertices; AB\vec{AB}, BC\vec{BC} and CA\vec{CA}.

The Law of Cosines in 3D states that the square of the length of one side of a triangle is equal to the sum of the squares of the lengths of the other two sides, minus twice the product of the lengths of those other two sides and the cosine of the angle between them. In mathematical notation:

AB2=BC2+CA22BCCAcosA|\vec{AB}|^2 = |\vec{BC}|^2 + |\vec{CA}|^2 - 2|\vec{BC}||\vec{CA}|\cos\angle{A}

where AB|\vec{AB}| is the length of the side opposite to vertex AA, and A\angle{A} is the angle between the sides opposite to vertices BB and CC.

Similarly, we can write the Law of Cosines for the other vertices:

BC2=CA2+AB22CAABcosB|\vec{BC}|^2 = |\vec{CA}|^2 + |\vec{AB}|^2 - 2|\vec{CA}||\vec{AB}|\cos\angle{B}
CA2=AB2+BC22ABBCcosC|\vec{CA}|^2 = |\vec{AB}|^2 + |\vec{BC}|^2 - 2|\vec{AB}||\vec{BC}|\cos\angle{C}

These equations are very useful in solving problems related to 3D geometry, such as finding the length of a side of a triangle given the coordinates of its vertices, or finding the angle between two sides of a triangle given their lengths and the coordinates of their endpoints.

Let's consider an example. Suppose we have a triangle with vertices at (1,2,3)(1, 2, 3), (4,5,6)(4, 5, 6) and (7,8,9)(7, 8, 9). We can find the length of the side opposite to the vertex at (4,5,6)(4, 5, 6) using the Law of Cosines in 3D:

AB2=BC2+CA22BCCAcosA|\vec{AB}|^2 = |\vec{BC}|^2 + |\vec{CA}|^2 - 2|\vec{BC}||\vec{CA}|\cos\angle{A}

where AB=ba=(415263)=(333)\vec{AB} = \vec{b} - \vec{a} = \begin{pmatrix} 4-1 \\ 5-2 \\ 6-3 \end{pmatrix} = \begin{pmatrix} 3 \\ 3 \\ 3 \end{pmatrix}, BC=cb=(748596)=(333)\vec{BC} = \vec{c} - \vec{b} = \begin{pmatrix} 7-4 \\ 8-5 \\ 9-6 \end{pmatrix} = \begin{pmatrix} 3 \\ 3 \\ 3 \end{pmatrix}, AB=BC=32+32+32=27|\vec{AB}| = |\vec{BC}| = \sqrt{3^2 + 3^2 + 3^2} = \sqrt{27}, and A\angle{A} is the angle between BC\vec{BC} and CA\vec{CA}. We can find this angle using the dot product of the vectors:

cosA=BCCABCCA=(333)(666)27108=13\cos\angle{A} = \frac{\vec{BC}\cdot\vec{CA}}{|\vec{BC}||\vec{CA}|} = \frac{\begin{pmatrix} 3 \\ 3 \\ 3 \end{pmatrix}\cdot\begin{pmatrix} -6 \\ -6 \\ -6 \end{pmatrix}}{\sqrt{27}\sqrt{108}} = -\frac{1}{3}

Substituting these values in the Law of Cosines in 3D, we get:

AB2=BC2+CA22BCCAcosA27=27+CA2227CA(13)CA2=27+18=45CA=45|\vec{AB}|^2 = |\vec{BC}|^2 + |\vec{CA}|^2 - 2|\vec{BC}||\vec{CA}|\cos\angle{A} \\ \Rightarrow 27 = 27 + |\vec{CA}|^2 - 2\sqrt{27}|\vec{CA}|\left(-\frac{1}{3}\right) \\ \Rightarrow |\vec{CA}|^2 = 27 + 18 = 45 \\ \Rightarrow |\vec{CA}| = \sqrt{45}

Therefore, the length of the side opposite to the vertex at (4,5,6)(4, 5, 6) is 45\sqrt{45}.

In conclusion, the Law of Cosines in 3D is a very useful formula in solving problems related to three-dimensional geometry. It relates the lengths of the sides of a triangle to the cosine of one of its angles, and can be used to find the length of a side of a triangle given the coordinates of its vertices, or to find the angle between two sides of a triangle given their lengths and the coordinates of their endpoints.

3D余弦定[JA]