Skip to main content

Pyhton library for simple physics modelation

Project description

About

This library can help you program some simple kinematics processes and get some important (maybe) data from it

Getting saterted

Installing

To install phyengine, run following command in command prompt:

pip install phyengine

Importing

IMPORTANT!!! You need to use a bit special import to use features!:

from phyengine import phyengine

Basic acknowledge

Vectors

Phyengine can work with 2d vectors. General syntax to create vector object is

phyengine.math_engine.Vector(<coordx>, <coordy>)

For example:

first = phyengine.math_engine.Vector(2, 3)

To get coord of vector, try this:

print(first.x)
print(first.y)

# Output:
# 2
# 3

Also, you can print vector:

print(first)

# Output:
# Vector object with coords (2, 3)

Operations with vectors

Addition/Substracting

a = phyengine.math_engine.Vector(2, 3)
b = phyengine.math_engine.Vector(3, -7)

res1 = a + b
res2 = a - b
print(res1)
print(res2)

# Output:
# Vector object with coords (5, -4)
# Vector object with coords (-1, 10)

Multiplying/Dividing vector by int/float

a = phyengine.math_engine.Vector(5, 6)
b = 1.2
c = 2

res1 = a * b
res2 = a / c
print(res1)
print(res2)

# Output:
# Vector object with coords (6, 7.2)
# Vector object with coords (2.5, 3)

Iterating by vector

Iterating by vector is equal to iterating by tuple (vector.x, vector.y)

a = phyengine.math_engine.Vector(5, 6)

for i in a:
    print(i)

# Output:
# 5
# 6

Getting absolute value of vector

Absolute value of vector is calculated as sqrt(vector.x^2 + vector.y^2)

a = phyengine.math_engine.Vector(3, 4)

print(abs(a))

# Output:
# 5

Getting unit vector

Unit vector is a vector, which absolute value is 1 and has the same direction as given

a = phyengine.math_engine.Vector(3, 4)

e = a.unit
print(e)

# Output:
# Vector object with coords (0.6, 0.8)

Creating window

So, let`s create our first window! General syntax to do it is:

window = phyengine.main_engine.Vector(<width>, <height>, <ping>, <scale>)

where:

width: integer - width of window (pixels)
height: integer - height of window (pixels)
ping: integer (30 by default) - time in ms between screen updating. The more ping is, the rarelier screen will be updated but the more stable it will be
scale: float (1 by default) - number that will show how many pixels are in one meter (scale = 10 mean that every 10 pixels program will understand as 1 imaginary meter)

For example:

window = phyengine.main_engine.Vector(600, 600, 5, 100)

But to show window you need to add next command:

window = phyengine.main_engine.Vector(600, 600, 5, 100)
window.start()

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

phyengine-1.2.5.3.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phyengine-1.2.5.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file phyengine-1.2.5.3.tar.gz.

File metadata

  • Download URL: phyengine-1.2.5.3.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for phyengine-1.2.5.3.tar.gz
Algorithm Hash digest
SHA256 714f6c058b6e7b165c769581bcfb148ecded3ddf2aefdce5a3e2642e740f9e88
MD5 28bb90972acb41f3f2d2f6e8655f078b
BLAKE2b-256 1447438cb6bfbf7580e3983c196dd8d57e2a7193905dfb3ce0710f6506db2b3b

See more details on using hashes here.

File details

Details for the file phyengine-1.2.5.3-py3-none-any.whl.

File metadata

  • Download URL: phyengine-1.2.5.3-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for phyengine-1.2.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5311dae674b72a04805ffc4f6cfa11b0d7909619e969843e984d014deb5825f4
MD5 3a57a964ba707691de5b11c7b5c28ea6
BLAKE2b-256 79068c30b10b35fd9ab7cfc51f1adb3e260e7cbff2f2f1d787ec31f004301fbf

See more details on using hashes here.

Supported by

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