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_thetaReturn cosine of polar angle from -1 to 1
magAlias for
Vector.magnitudemagnitudeReturn magnitude of vector
ndarrayGet the underlying numpy array.
normReturn normalized Vector
phiReturn azimuth angle in rad from -PI to PI
phi_degReturn azimuth angle in degree from -180 to 180
thetaReturn polar angle in rad from 0 to PI e
theta_degReturn polar angle in degree from 0 to 180
xx-Component of Vector
yy-Component of Vector
zz-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.]