Skip to main content

A simple complex vector package

Project description

Cvectors

Cvectors is a Python package for using complex numbers as vectors. It provides a single class, Vector, which inherits from complex.

Usage is as follows:

>>> from cvectors import Vector
>>> foo = Vector(4, 3)
>>> foo
Vector(4.0, 3.0)
>>> foo.x
4.0
>>> foo.y
3.0
>>> foo.r
5.0
>>> bar = Vector(4, 5)
>>> foo + bar
Vector(8.0, 8.0)
>>> foo.dot(bar)
31.0
>>> foo.rotate(90, "deg")
Vector(-2.999999999999999, 4.000000000000001)
>>> Vector(r=3, theta=5) - Vector(r=5, theta=2)
Vector(2.9317207391253906, -7.423259958117824)
>>> Vector(5, 6).perp_dot(Vector(-6, 1))
41.0
>>> abs(foo)
5.0
>>> Vector(1, -9).rec()
(1.0, -9.0)
>>> Vector(1, -9).pol()
(9.055385138137417, -1.460139105621001)
>>> Vector(3, 2).perp()
Vector(-2.0, 3.0)
>>> Vector(3.142, 2.718).round()
(3.0, 3.0)
>>> Vector(3.142, 2.718).round(1)
(3.1, 2.7)

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

cvectors-5.0.1.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

cvectors-5.0.1-py3-none-any.whl (16.0 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