# Module Scientific.Geometry

This subpackage contains classes that deal with geometrical quantities and objects. The geometrical quantities are vectors and tensors, transformations, and quaternions as descriptions of rotations. There are also tensor fields, which were included here (rather than in the subpackage Scientific.Functions) because they are most often used in a geometric context. Finally, there are classes for elementary geometrical objects such as spheres and planes.

# Submodules:

- Module Scientific.Geometry.Objects3D

- Module Scientific.Geometry.Quaternion

- Module Scientific.Geometry.TensorAnalysis

- Module Scientific.Geometry.Transformation

## Class Tensor: Tensor in 3D space

Constructor: Tensor([[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]])

Tensors support the usual arithmetic operations (`t1`, `t2`: tensors, `v`: vector, `s`: scalar):

- `t1+t2` (addition)

- `t1-t2` (subtraction)

- `t1*t2` (tensorial (outer) product)

- `t1*v` (contraction with a vector, same as t1.dot(v.asTensor()))

- `s*t1`, `t1*s` (multiplication with a scalar)

- `t1/s` (division by a scalar)

The coordinates can be extracted by indexing; a tensor of rank N can be indexed like an array of dimension N.

Tensors are immutable, i.e. their elements cannot be changed.

Tensor elements can be any objects on which the standard arithmetic operations are defined. However, eigenvalue calculation is supported only for float elements.

Methods:

- asVector()

  Returns an equivalent vector object (only for rank 1).

- dot(other)

  Returns the contraction with other.

- trace(axis1=`0`, axis2=`1`)

  Returns the trace of a rank-2 tensor.

- transpose()

  Returns the transposed (index reversed) tensor.

- symmetricalPart()

  Returns the symmetrical part of a rank-2 tensor.

- asymmetricalPart()

  Returns the asymmetrical part of a rank-2 tensor.

- eigenvalues()

  Returns the eigenvalues of a rank-2 tensor in an array.

- diagonalization()

  Returns the eigenvalues of a rank-2 tensor and a tensor representing the rotation matrix to the diagonalized form.

- inverse()

  Returns the inverse of a rank-2 tensor.

## Class Vector: Vector in 3D space

Constructor:

- Vector(x, y, z) (from three coordinates)

- Vector(coordinates) (from any sequence containing three coordinates)

Vectors support the usual arithmetic operations (`v1`, `v2`: vectors, `s`: scalar):

- `v1+v2` (addition)

- `v1-v2` (subtraction)

- `v1*v2` (scalar product)

- `s*v1`, `v1*s` (multiplication with a scalar)

- `v1/s` (division by a scalar)

The three coordinates can be extracted by indexing.

Vectors are immutable, i.e. their elements cannot be changed.

Vector elements can be any objects on which the standard arithmetic operations plus the functions sqrt and arccos are defined.

Methods:

- x()

  Returns the x coordinate.

- y()

  Returns the y coordinate.

- z()

  Returns the z coordinate.

- length()

  Returns the length (norm).

- normal()

  Returns a normalized copy.

- cross(other)

  Returns the cross product with vector other.

- asTensor()

  Returns an equivalent tensor object of rank 1.

- dyadicProduct(other)

  Returns the dyadic product with vector or tensor other.

- angle(other)

  Returns the angle to vector other.