Mathematics

Vectors

A vector is an object that has a magnitude and a direction. It has two or more elements. For three dimensional geometry we will use three vectors of the form \(\vec{P} = (p_1, p_2 ,p_3)\).

The magnitude of a vector is also known as its modulus.

\[|\vec{P}| = \sqrt{p_1^2 + p_2^2 + p_3^2}\]

When used in geometry a vector is a position relative to an origin vector \(\vec{O} = (0, 0, 0)\).

A unit vector has a magnitude of unity and is purely used for defining a direction. A unit vector can be created from any vector by dividing it by its modulus.

\[\hat{p} = \frac{\vec{P}}{|\vec{P}|}\]

Dot Product

The dot product of two vectors is a scalar value.

\[\vec{a}\cdot\vec{b} = a_1b_1 + a_2b_2 + a_3b_3\]

The dot product of a vector and itself is the square of its modulus \(\vec{a}\cdot\vec{a} = |\vec{a}|^2\).

Cross Product

The cross product of two vectors is a vector which is perpendicular to both vectors.

\[\vec{a}\times\vec{b} = (a_2b_3 - a_3b_2, a_3b_1 - a_1b_3, a_1b_2 - a_2b_1)\]

Line Vectors

A line vector is defined by a position \(\vec{P} = (x_0, y_0, z_0)\) on the line, the direction of the line \(\hat{n}\) and a scalar variable \(\lambda\).

\[\vec{P} = \lambda\hat{n}\]

This can be written in terms of coordinates.

\[\lambda = \frac{x - x_0}{n_x} = \frac{y - y_0}{n_y} = \frac{z - z_0}{n_z}\]

To calculate the intersection with another object, the coordinates can be replaced with the scalar parameter. The intersection can be solved for the parameter and then the coordinates recovered.

\[x = x_0 + \lambda n_x;\quad y = y_0 + \lambda n_y;\quad x = z_0 + \lambda n_z\]

Vector Plane

A plane can be defined by a position \(\vec{p_0}\) on the plane and a normal vector \(\hat{n}\).

\[(\vec{p} - \vec{p_0})\cdot\hat{n} = 0\]

A plane can also be defined from three positions.

\[\vec{n} = (\vec{p_1} - \vec{p_0})\times(\vec{p_2} - \vec{p_0})\]
\[(\vec{p} - \vec{p_0})\cdot\hat{n} = 0\]

Intersection of Two Planes

The intersection of two planes doesn’t exist if the planes are parallel. If it does exist it is a line which is normal to both planes.

The two planes are \(\vec{r}\cdot\hat{n_1} = h_1\) and \(\vec{r}\cdot\hat{n_2} = h_2\). The direction of the line of intersection is normal to both planes \(\hat{n_1}\times\hat{n_2}\). The equation of the line is:

\[\vec{r} = c_1\hat{n_1} + c_2\hat{n_2} + \lambda(\hat{n_1}\times\hat{n_2})\]

Take the dot product with each normal.

\[\vec{r}\cdot\hat{n_1} = h_1 = c_1 + c_2(\hat{n_2}\cdot\hat{n_1})\]
\[\vec{r}\cdot\hat{n_2} = h_2 = c_1(\hat{n_1}\cdot\hat{n_2}) + c_2\]

Multiply Equation (13) by \((\hat{n_1}\cdot\hat{n_2})\).

\[h_2(\hat{n_1}\cdot\hat{n_2}) = c_1(\hat{n_1}\cdot\hat{n_2})^2 + c_2(\hat{n_1}\cdot\hat{n_2})\]

Subtract Equation (12) from Equation (14).

\[h_2(\hat{n_1}\cdot\hat{n_2}) - h_1 = c_1(\hat{n_1}\cdot\hat{n_2})^2 - c_1\]

Reorganise Equation (15).

\[c_1 = \frac{h_1 - h_2(\hat{n_1}\cdot\hat{n_2})}{1 - (\hat{n_1}\cdot\hat{n_2})^2}\]

Eliminate \(c_1\) is a similar way.

\[c_2 = \frac{h_2 - h_1(\hat{n_1}\cdot\hat{n_2})}{1 - (\hat{n_1}\cdot\hat{n_2})^2}\]

Intersection of Line and Ellipsoid

The equation of an ellipsoid.

\[\frac{x^2}{a^2} + \frac{y^2}{b^2} + \frac{z^2}{c^2} = 1\]

Where \(a\), \(b\) and \(c\) are the semi-axis lengths.

Substitute Equation (7) into Equation (18) and multiply by the semi-axis squares.

\[b^2c^2(x_0 + \lambda n_x)^2 + a^2c^2(y_0 + \lambda n_y)^2 + a^2b^2(z_0 + \lambda n_z)^2 = a^2b^2c^2\]

Collect the terms in Equation (19).

\[\lambda^2(n_x^2b^2c^2 + n_y^2a^2c^2 + n_z^2a^2b^2) + 2\lambda(x_0n_xb^2c^2 + y_0n_ya^2c^2 + z_0n_za^2b^2) + x_0^2b^2c^2 + y_0^2a^2c^2 + z_0^2a^2b^2 - a^2b^2c^2 = 0\]

This is a quadratic equation that can be solved for \(\lambda\). Take the positive square root of the discriminant. The coordinates of the intersection can be calculated from Equation (7).

Copyright (C) 2019 - 2026 Dr Phill Edwards, All Rights Reserved