Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dylannalex committed Jul 9, 2022
1 parent 34953eb commit e73a202
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 34 deletions.
6 changes: 3 additions & 3 deletions curvipy/graphing_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def draw_vector(

vector_coordinates = (head[0] - tail[0], head[1] - tail[1])

# Check if vector is the cero vector (v = <0, 0>)
# Check if vector is the cero vector (v = [0, 0])
vector_norm = sqrt(vector_coordinates[0] ** 2 + vector_coordinates[1] ** 2)
if vector_norm == 0:
return
Expand Down Expand Up @@ -161,8 +161,8 @@ def draw_animated_curve(
y_axis_scale: int = 10,
) -> None:
"""
Given a parametrized function f(t) = <x(t), y(t)>, draws a the
set of vectors {<x(t), y(t)> | t e domain_interval} and then
Given a parametrized function f(t) = [x(t), y(t)], draws a the
set of vectors {[x(t), y(t)] | t e domain_interval} and then
draws f(t) graph.
:param parametrized_function: curve to draw
Expand Down
42 changes: 17 additions & 25 deletions docs/graphing_calculator.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,21 @@ from curvipy import GraphingCalculator


graphing_calculator = GraphingCalculator(
background_color="white",
curve_color="black",
curve_width=3,
vector_color="green",
window_title="curvipy",
drawing_speed=11,
background_color="#F1FAEE",
curve_color="#457B9D",
curve_width=4,
vector_color="#E63946",
vector_width=3,
vector_head_size=10,
show_axis=True,
axis_color="grey",
axis_color="#A8DADC",
axis_width=2,
)
# The attribute values shown above are the default values
```

- _**background_color:**_ color name or hex code
- _**curve_color:**_ color name or hex code
- _**curve_width:**_ integer value
- _**vector_color:**_ color name or hex code
- _**vector_width:**_ integer value
- _**vector_head_size:**_ integer value
- _**show_axis:**_ boolean value
- _**axis_color:**_ color name or hex code
- _**axis_width:**_ integer value


All this are public attributes. You can easily change their value as shown below:

```python
Expand All @@ -49,7 +40,7 @@ graphing_calculator.vector_color = "#FF5A5F"

#### :round_pushpin: graphing_calculator.draw_curve()

This method draws the given curve.
This method draws a given curve.

```python
graphing_calculator.draw_curve(curve, domain_interval, x_axis_scale=10, y_axis_scale=10)
Expand Down Expand Up @@ -103,16 +94,16 @@ graphing_calculator.draw_curve(f, (-10, 10), y_axis_scale=1)

#### :round_pushpin: graphing_calculator.draw_animated_curve()

This method is based on the idea that the graph of a parametrized function ```f(t) = <x(t), y(t)>``` is nothing but the curve formed by joining all the vectors ```<x(t), y(t)>``` head. <br>
```graphing_calculator.draw_animated_curve()``` illustrates that by first drawing the set of vectors ```{<x(t), y(t)> | t ∈ R}``` and then joining their head.
This method is based on the idea that the graph of a parametrized function **f(t) = [x(t), y(t)]** is nothing but the curve formed by joining all the vectors **[x(t), y(t)]** head. <br>
```graphing_calculator.draw_animated_curve()``` illustrates that by first drawing the set of vectors **{[x(t), y(t)] | t ∈ R}** and then joining their heads.

```python
graphing_calculator.draw_animated_curve(
parametrized_function, domain_interval, vector_frequency, x_axis_scale, y_axis_scale
)
```

- _**parametrized_function:**_ curve's parametrized function
- _**parametrized_function:**_ curves parametrized function
- _**domain_interval:**_ curve function domain interval
- _**vector_frequency:**_ the frequency which vectors will be drawn. The lower frequency the more vectors (default is 2)
- _**x_axis_scale:**_ integer to scale x axis (default is 10)
Expand All @@ -125,19 +116,20 @@ def f(t):
graphing_calculator.draw_animated_curve(f, (-10, 10), vector_frequency=3)
```

```vector_frequency=3``` means that a vector will be drawn every time ```t``` changes 3 units, starting by ```t=-10``` (which is the first value of our domain interval). This means that for the values of ```t``` ```{-10, -7, -4, -1, 2, 5, 8}``` a vector will be drawn, generating the following set of vectors: ```{f(-10), f(-7), f(-4), f(-1), f(2), f(5), f(8)}```. <br>
Setting a negative value for ```vector_frequency``` wont draw any vector. In this scenario ```graphing_calculator.draw_animated_curve()``` will produce the same result as ```graphing_calculator.draw_curve()```.
```vector_frequency=3``` means that a vector will be drawn every time **t** changes 3 units, starting by **t=-10** (which is the first value of our domain interval). This means that for the values of **t** **{-10, -7, -4, -1, 2, 5, 8}** a vector will be drawn, generating the following set of vectors: **{f(-10), f(-7), f(-4), f(-1), f(2), f(5), f(8)}**. <br>
Setting a negative value for ```vector_frequency``` wont draw any vector.


#### :round_pushpin: graphing_calculator.draw_vector()

This method draws the given vector.
This method draws a two-dimensional vector

```python
graphing_calculator.draw_vector(vector, x_axis_scale=10, y_axis_scale=10)
graphing_calculator.draw_vector(head, tail=(0,0), x_axis_scale=10, y_axis_scale=10)
```

- _**vector:**_ two-dimensional vector to draw
- _**head:**_ vector ending point
- _**tail:**_ vector starting point (default is the origin (0, 0))
- _**x_axis_scale:**_ integer to scale x axis (default is 10)
- _**y_axis_scale:**_ integer to scale y axis (default is 10)

Expand Down
4 changes: 2 additions & 2 deletions docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ graphing_calculator = GraphingCalculator()

The next step is to define the curve you want to draw. In **curvipy** this can be done by:

- Defining the curve as a function ```y = f(x)```:
- Defining the curve as a function **y = f(x)**:

```python
def square_root(x):
Expand All @@ -21,7 +21,7 @@ def square_root(x):
graphing_calculator.draw_curve(square_root, (0, 25)) # We want to draw the function from x = 0 to x = 25
```

- Defining the curve as a parametrized function ```f(t) = <x(t), y(t)>```:
- Defining the curve as a parametrized function **f(t) = <x(t), y(t)>**:

```python
def square_root(t):
Expand Down
8 changes: 4 additions & 4 deletions docs/lintrans.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ from curvipy import lintrans

### :pushpin: Applying linear transformations to curves

A parametrized function ```f(t) = <x(t), y(t)>``` image is the set of vectors ```{<x(t), y(t)> | t ∈ R}```. ```f(t)``` graph is nothing but the curve formed by joining all the vectors head, in other words, ```f(t)``` graph is the set of points ```{P(x(t), y(t)) | t ∈ R}```.<br>
A parametrized function **f(t) = [x(t), y(t)]** image is the set of vectors **{[x(t), y(t)] | t ∈ R}**. **f(t)** graph is nothing but the curve formed by joining all the vectors head, in other words, **f(t)** graph is the set of points **{P(x(t), y(t)) | t ∈ R}**.<br>

Applying linear transformations to curves is based on the idea that applying a linear transformation ```T``` to ```f(t)``` can be thought as applying ```T``` to each vector in ```{<x(t), y(t)> | t ∈ R}```. This means that ```T(f(t))``` image is ```{T(<x(t), y(t)>) | t ∈ R}``` and its graph is the curve formed by joining the vectors head in that set.
Applying linear transformations to curves is based on the idea that applying a linear transformation **T** to **f(t)** can be thought as applying **T** to each vector in **{[x(t), y(t)] | t ∈ R}**. This means that **T(f(t))** image is **{T([x(t), y(t)]) | t ∈ R}** and its graph is the curve formed by joining the vectors head in that set.

_**NOTE:**_ because of the explained above, this module only works with curves defined as parametrized functions.

Expand Down Expand Up @@ -79,7 +79,7 @@ lintrans.transform_curve(curve, transformation_matrix)
**Example:**

```python
# Imagine we want to define the following transformation matrix:
# Lets say we want to define the following transformation matrix:
#
# transformation_matrix = [ 1 2 ]
# [ 3 4 ]
Expand All @@ -88,7 +88,7 @@ lintrans.transform_curve(curve, transformation_matrix)

transformation_matrix = [[1, 2], [3, 4]]

# Or we can use numpy arrays (which might be more useful):
# Or we can use numpy arrays:

import numpy as np
transformation_matrix = np.array(((1, 2), (3, 4)))
Expand Down

0 comments on commit e73a202

Please sign in to comment.