VectorUtil

The VectorUtil class is used to work with vectors.

To import this class use:

import ru.biosoft.physicell.biofvm.VectorUtil

All members of the VectorUtil class are presented below.

Members of the VectorUtil class

Class member

Description

static double[] newDiff(double[] vector1, double[] vector2)

vector1 is a three-dimensional vector.
vector2 is a three-dimensional vector.

Returns a three-dimensional vector that is the coordinate difference of the vectors vector1 and vector2.

Example of usage.

static double norm(double[] vector)

vector - a three-dimensional vector.

Returns the L2-norm of a vector.

Example of usage.

static double norm_squared(double[] vector)

vector - a three-dimensional vector.

Returns the square L2-norm of vector.

Example of usage.

static double[] newNormalize(double[] vector)

vector - a three-dimensional vector.

Returns the normalized vector.

Example of usage.

static void normalize(double[] vector)

vector - a three-dimensional vector.

Normalizes vector.

Example of usage.

static double dist(double[] vector1, double[] vector2)

vector1 is a three-dimensional vector.
vector2 is a three-dimensional vector.

Returns the distance between vectors vector1 and vector2.

Example of usage.

static double[] newProd(double[] vector, double const)

vector - a three-dimensional vector.
const - number.

Returns a three-dimensional vector res_vector of the following form:
res_vector[i] = const*vector[i],
where i is each coordinate of the vectors res_vector and vector.

Example of usage.

static double[] axpy(double[] vector1, double const, double[] vector2)

vector1 is a three-dimensional vector.
const - number.
vector2 is a three-dimensional vector.

Returns a three-dimensional vector of the following form:
vector[i] = vector1[i] + const*vector2[i],
где i - каждая координата векторов vector, vector1 и vector2.

Example of usage.

static void zero(double[] vector)

vector - a three-dimensional vector.

Zeroes all vector coordinates.

Example of usage.

Vector Operations Help

Coordinate vector difference

The coordinate difference of vectors is a vector subtraction operation in which the corresponding components (coordinates) of the vectors are subtracted.

Example
// Given
Vector3D a = new Vector3D(5, 3, 7);
Vector3D b = new Vector3D(1, 2, 4);

// Component-wise difference
Vector3D difference = a.subtract(b); // Result: (4, 1, 3)

L2-norm of a vector

The L2 norm of a vector (Euclidean norm) is a standard way of measuring the length of a vector. It is calculated as the square root of the sum of the squares of all vector components.

For a vector v = (v1, v2, ..., vn) in n-dimensional space:

\[\|v\|_2 = \sqrt{v_1^2 + v_2^2 + \cdots + v_n^2}\]

Vector normalization

Vector normalization is the transformation of a vector into a unit-length vector (with L2-norm equal to 1) preserving its direction.

The normalized version of the vector v = (v1, v2, ..., vn) is a vector v`, each coordinate of which is less than the corresponding coordinate of the vector v in the L2 norm of that vector:

\[{v'}_i = \frac{v_i}{\sqrt{v_1^2 + v_2^2 + \cdots + v_n^2}}, \quad \text{where } i = 1, 2, \ldots, n.\]

Расстояние между векторами

В двумерной системе координат расстояние (d) между векторами A(x1, y1) и B(x2, y2) вычисляется следующим образом:

\[d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\]

В трехмерной системе координат расстояние (d) между векторами A(x1, y1, z1) и B(x2, y2, z2) вычисляется следующим образом:

\[d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}\]