#+TITLE: pyFreeBody Documentation

* Getting Started
** Install
Use the following Pypi package:
#+begin_src bash
pip3 install pyfreebody
#+end_src
*** Font Setup
The font used in the diagram is sourced from /~\/pyfreebody.ttf/. You can use the following to download and setup the default font, or you can add your own by replacing the default one.
#+begin_src bash
curl -L https://github.com/danalves24com/pyfreebody/raw/main/SourceCodePro-Regular.ttf -o ~/pyfreebody.ttf
#+end_src
** Importing
pyFreeBody exports many components which you can summon from
#+begin_src python
import pyfreebody.pyfreebody
#+end_src
From /pyfreebody/ you can import the following:
+ Freebody
+ Direction
+ SystemType
#+begin_src python
from pyfreebody.pyfreebody import Freebody, Direction, SystemType
#+end_src
* Creating a Freebody Object
+ name : what you want the Freebody system called
+ mass : mass of the object in context
+ type : the type of system
#+begin_src python
body = Freebody("DiagramName", mass, SystemType.TYPE)
#+end_src

* Data
** System Type
A system type determines how the diagram will be shown. Currently supported system types are the following:
+ basic
+ inclinedPlane
*** Inclined Plane
+ name
+ mass
+ type = inclinedPlane
+ incline(radians)
#+begin_src python
body = Freebody("DiagramName", mass, SystemType.inclinedPlane, math.pi/6)
#+end_src
*** Basic
+ name
+ mass
+ type = basic
#+begin_src python
body = Freebody("DiagramName", mass, SystemType.basic)
#+end_src
** Direction
Direction carries a theta value for the sake of easier implementation. There are only 4 main directions implemented:
+ up
+ down
+ left
+ right
#+NAME: Implementation of direction up
#+begin_src python
body.addForce("Normal", 300, Direction.up) # name, magnitude, theta
#+end_src

* Functions
** Adding a force
To add a force to the object in your diagram, use the following function. The function takes 3 parameters.
#+begin_src python
# magnitude : the strength of the force
# theta : the angle the force makes with the horizontal
body.addForce("ForceName", magnitude, theta)
#+end_src
** Creating the diagram
To create the configuration the diagram, simply execute:
#+begin_src python
body.diagram()
#+end_src
This will save the diagram under /pyfreebody-DiagramName.png/
* Complete Example
#+NAME: freebody
#+begin_src python :session Python3 :exports both :noweb yes :file pyfreebody-fbg1.png :results graphics file
from pyfreebody.pyfreebody import Freebody, Direction, SystemType
body = Freebody("fbg1", 30, SystemType.basic) # name, mass

body.addForce("Normal", 300, Direction.up) # name, magnitude, theta
body.addForce("Pull", 2, Direction.left ) # name, magnitude, theta

body.diagram() # creates the diagram
#+end_src
