A package to work with 3D vectors in Spherical and Cartesian coordinates.
Project description
threedvector Package
threedvector is a package providing common methods for working with 3D vectors in both Spherical and Cartesian coordinates.
Vectors are stored in Spherical format but can be created in both Spherical and Cartesian formats.
Methods
init(radius_x=0, theta_y=0, phi_z=0, coords="spherical")
Default Vector creation is in the Spherical coordinate system with radius_x
representing the length of the vector, theta_y
the angle theta and phi_z
the angle phi. A Vector can be created using Cartesian coordinates when coords
is set to "cartesian". In this case radius_x
represents the x
coordinate, theta_y
the y
coordinate and phi_z
the z
coordinate.
to_spherical([x, y, z])
Returns a Vector object based on [x, y, z]
Cartesian cooridates.
to_cartesian()
Returns a list in the form of [x, y, z]
representing the corresponding Cartesian coordinates for a vector.
is_same(s_vector)
Compares the length as well as angles theta and phi of vector and s_vector
to determine equality. This is different to '=' which only checks for equality of the vector length.
dot(s_vector)
Returns the resultant scalar dot product of a vector with s_vector
.
cross(s_vector)
Returns Vector
resulting from the cross product of a vector with s_vector
.
angle(s_vector)
Returns the in-plane angle between a vector and s_vector
.
magnitude()
Returns the length of a vector.
unit()
Returns the corresponding unit vector of a vector.
addition and subtraction
Returns resulting Vector. Normal addition and subtraction is done through Cartesian addition and subtraction operations.
multplication
Multiplication is implemented as scalar multiplication only. For dot and cross products the corresponding methods should be used.
comparison
All comparison operators returns comparison with length of vectors only.
Atributes
radius
Returns the length of a vector
theta
Returns the angle theta of a vector in degrees
phi
Returns the ancle phi of a vector in degrees
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for threedvector-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d6bc45dc9aeccc7237650bdd219cb32706716837fcf8cf37e5674031e0a1870 |
|
MD5 | 8e25113582407ef88bdcf627e3a6f4da |
|
BLAKE2b-256 | 927f3987b248195edfb5b9d855937645eb8d080aa52ece8b79d12c7de61763e6 |