Skip to main content

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

copy(other)

Returns a Vector object representing a copy of other

Instance 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.

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

set_magnitude(magnitude)

Sets the length of a vector to magnitude

set_theta(theta)

Sets the polar angle, theta, of a vector to theta in degrees

set_phi(phi)

Sets the azimuthal angle, phi, of a vector to phi 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

threedvector-0.3.3.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

threedvector-0.3.3-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page