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

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 "sperical". 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 in degrees 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


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.0.9.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

threedvector-0.0.9-py3-none-any.whl (4.3 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