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 where coords
is set to "spherical". radius_x
represents the length of the vector, theta_y
the polar angle, theta and phi_z
the azimuthal angle, phi.
A Vector can be created using Cartesian coordinates with coords
set to "cartesian" instead of "spherical". In this case radius_x
represents the x
coordinate, theta_y
the y
coordinate and phi_z
the z
coordinate.
cartesian()
Returns a list
in the form of [x, y, z]
representing the corresponding Cartesian coordinates of a vector.
is_same(s_vector)
Compares the length as well as angles theta and phi of vector with s_vector
to determine equality. This is different to '=' which only checks for equality of the vector length.
dot(s_vector)
Returns a float
as the resultant dot product of a vector with s_vector
.
cross(s_vector)
Returns the Vector
object resulting from the cross product of a vector with s_vector
.
angle(s_vector)
Returns a float
as the in-plane angle in degrees between a vector and s_vector
.
magnitude()
Returns a float
as the length of a vector.
unit()
Returns a Vector
object as the corresponding unit vector of a vector.
magnitude()
Returns a float
as the length of a vector
theta()
Returns a float
as the polar angle theta of a vector in degrees
phi()
Returns a float
as the azimuthal angle phi of a vector in degrees
addition and subtraction
Returns resulting Vector
object. Normal addition and subtraction are done through Cartesian addition and subtraction operations.
multiplication
Multiplication is implemented as scalar multiplication only. For dot and cross products, the corresponding methods should be used.
comparison
All comparison operators return comparison with length of vectors only.
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.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13f5607b8b0553d66814d53851f656edbf392134c87b94f527510c5477d1c204 |
|
MD5 | f9fd982b3070d96c14784e1bee7a3000 |
|
BLAKE2b-256 | 8e88e5bf57dcea5af95811e135f26b86da3b59b74846bd091adc1d62854ce915 |