# MathJs Tutorial 3: Arrows and Lines

{% hint style="info" %}
This page is under construction, but will be completed soon.
{% endhint %}

{% hint style="warning" %}
This page is **out of date** and does not accurately represent the current user interface nor recent changes that we have made to the Tychos language. We are in the process of updating all of our documentation. Thank you for your patience!
{% endhint %}

## Visualizing Vectors

Tychos does have a tool for allowing us to draw vector arrows - its a function called `drawArrow.` The `drawArrow()` function draws an arrow and is commonly used to illustrate vectors for many different kinds of vector quantities such as velocity, force etc. The function `drawArrow()` should be called in the Calculations editor because it only draws the arrow for the current frame. If you call `drawArrow()` in the Initial State editor, you will not see anything.

The syntax for using this function looks like this:

```
drawArrow([0, 0], [10, 10], "green")
```

This will draw an arrow that starts at the point \[0, 0] and then extends to the point \[10, 10] and is the color green. So the inputs for the function are as follows:

`drawArrow(pos, size, color, components)`

* `pos` — coordinates for the starting point of the arrow as an \[X,Y] matrix.
* `size` — the vector to illustrate, e.g. \[10, 0] will draw an arrow 10 units to the right.
* `color` — Optional color value for your arrow, e.g. "red" or an HTML value like "#ff0000".
* `components` — Optional flag that determines if vector components are drawn, a value of `true` displays the components.

The second input, the size, should be seen as the actual size of the vector, not the end point of the vector. So for example, if you want to draw the vector \[10, 10] but starting at the point \[0, 10], notice that the actual tip of the vector extends to the point in space of \[10, 20].

We can use this to visualize the position vector for a particle. This is done by using the position attribute as the vector to be drawn, and the origin as the starting point. You would draw a position vector for a particle called p1 using this code:

```
drawArrow([0, 0], p1.pos, "green") 
```

...which will result in a vector arrow that points from the origin to the center of the particle on the screen.

You can also visualize the vector components by adding *true* to the list of inputs in the *drawArrow* function like this:

```
drawArrow([0, 0], p1.pos, "green", true) 
```

This will display the component vectors for the diagonal vector.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tychos.org/docs/for-teachers/example-lessons/lesson-3-arrows-and-lines.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
