Skip to main content

A simple complex vector package.

Project description

Cvectors

Cvectors is a Python package for 2D vectors. It provides a class, Vector, which uses complex internally.

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
>>> import math
>>> foo.rotate(math.pi / 2)
Vector(-2.9999999999999996, 4.0)
>>> Vector.from_polar(r=3, theta=5) - Vector.from_polar(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, 3)
>>> 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-9.1.0.tar.gz (18.6 kB view hashes)

Uploaded Source

Built Distribution

cvectors-9.1.0-py3-none-any.whl (15.6 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