Vector

Vector math utils.

import nvtools as nv

# create new vectors
a = nv.Vector(1, -1, 1)
b = nv.Vector(2, 1, -3)

# useful methods
a.length
a.angle(b)
a.scalar_product(b)
a.cross_product(b)
class nvtools.vector.NVVector[source]

NV unit vectors.

property vectors

NV unit vectors.

\hat{n}_1 = \frac{1}{\sqrt{3}} \begin{pmatrix} 1 \\ 1 \\ 1 \end{pmatrix} \enspace
\hat{n}_2 = \frac{1}{\sqrt{3}} \begin{pmatrix} -1 \\ -1 \\ 1 \end{pmatrix} \enspace
\hat{n}_3 = \frac{1}{\sqrt{3}} \begin{pmatrix} -1 \\ 1 \\ -1 \end{pmatrix} \enspace
\hat{n}_4 = \frac{1}{\sqrt{3}} \begin{pmatrix} 1 \\ -1 \\ -1 \end{pmatrix}

class nvtools.vector.Vector(*args)[source]

N-dim Vector.

angle(other) float[source]

Angle between self and other in radians.

\text{angle} = \arccos\left(\frac{\vec{v}_1 \cdot \vec{v}_2}{|\vec{v}_1| |\vec{v}_2|}\right)

angle_normal(other) float[source]

Angle between self and normal vector of a plane.

\text{angle normal} = \arcsin\left(\frac{\vec{v}_1 \cdot \vec{n}_2}{|\vec{v}_1| |\vec{n}_2|}\right)

cross_product(other) Vector[source]

Cross Product between self and other.

property dim: float

Dimensionality.

property length: float

Euclidian length.

\text{length} = \sqrt{\sum_i v_i}

normalize() Vector[source]

Normalize to unit length.

rotate(u: Vector, theta: float) Vector[source]

Rotate around arbitrary axis.

Parameters:
  • u (Vector) – Rotation axis (Vector of arbitrary length)

  • theta (float) – Rotation angle in radians

scalar_product(other) float[source]

Scalar Product between self and other.

property x

X component.

property y

Y component.

property z

Z component.