Vector#

With the Vector class, atompy offers some linear algebra operations for vectors.

The underlying data structure is a NumPy ndarray.

class atompy.Vector(vectors)[source]#

Wrapper class for numpy arrays that represent vectors.

Parameters:
vectorsarray_like, shape (N, 3) or (3,)

a list of vectors [vec1, vec2, vec3, …]

Attributes:
cos_theta

Return cosine of polar angle from -1 to 1

mag

Alias for Vector.magnitude

magnitude

Return magnitude of vector

ndarray

Get the underlying numpy array.

norm

Return normalized Vector

phi

Return azimuth angle in rad from -PI to PI

phi_deg

Return azimuth angle in degree from -180 to 180

theta

Return polar angle in rad from 0 to PI e

theta_deg

Return polar angle in degree from 0 to 180

x

x-Component of Vector

y

y-Component of Vector

z

z-Component of Vector

Methods

angle_between(other)

Return the angle between Vector and other

copy()

Return deep copy

cross(other)

Return cross product between self and other

dot(other)

Returrn dot product of Vector with other

keep_where(mask)

Keep every vector i where mask[i] == True

remove_where(mask)

Remove every vector i where mask[i] == True

rotated_around_x(angle)

Return a new vector which is rotated around the x-axis by angle

rotated_around_y(angle)

Return a new vector which is rotated around the y-axis by angle

rotated_around_z(angle)

Return a new vector which is rotated around the z-axis by angle

Examples

>>> vec  = Vector([1, 2, 3])
>>> vecs = Vector([[1, 2, 3], [4, 5, 6]])
>>> vec.x
1.0
>>> vecs.x
[1. 4.]