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 all features:

from phyengine import MathEngine
from phyengine import MainEngine
from phyengine import DynamicObjectManager

You can also use ususal import

import phyengine

but you will have to use phyengine.MathEngine instead of simple MathEngine e.t.c

Basic acknowledge

Vectors

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

MathEngine.Vector(<coordx>, <coordy>)

For example:

first = MathEngine.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 = MathEngine.Vector(2, 3)
b = MathEngine.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 = MathEngine.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 = MathEngine.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 = MathEngine.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 = MathEngine.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 = MainEngine.BasicWindow(<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 = MainEngine.BasicWindow(600, 600, 5, 100)

But to show window you need to add next command:

window = MainEngine.BasicWindow(600, 600, 5, 100)
window.start()

Creating objects on screen

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.3.0.1.tar.gz (5.1 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.3.0.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for phyengine-1.3.0.1.tar.gz
Algorithm Hash digest
SHA256 6cee33b5b89c8e29acb5b10f0d748abe397c420c21ae856b963965780ec1167b
MD5 61b0a3603792c6ccf37dfebee26e21e1
BLAKE2b-256 8c00a71e14bb544abfaee7fb85a284c5f8b0b6b7d6c656382dd607428d5e3ab9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phyengine-1.3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 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.3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4188e9c2a2e6dff9dc61838e5de46995d4fb5299f3aaee9c2527bf474a17afba
MD5 ab4803cdf1917c90ae1ddf8818893b8c
BLAKE2b-256 ca7a09fc73f0f2155ae6e69ec1268a05057b08608a080a01f246b383a797084a

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