Tychos Docs
  • Tychos Documentation and Reference
  • General
  • Change Log
  • Python Demonstrations
  • MathJs Demonstrations
  • Our Team
  • Learn
    • Overview
    • Creating and Managing Scenarios
    • The Interface
    • Tychos Python Language Reference
    • Tychos MathJs Language Reference
    • Video Guides
      • Video Tutorial: An Overview
      • Video Tutorial: Settings
      • Video Tutorial: Animating Motion
      • Video Tutorial: Meters and Gauges
      • Video Tutorial: Graphs and Bar Charts
      • Video Tutorial: Arrows and Lines
      • Video Tutorial: Tables
  • For Teachers
    • Getting Started
    • Creating and Managing Classes
    • Giving Feedback: Comments
    • Tutorials (Python)
      • Python Tutorial 1: Introduction to Coding in Tychos
      • Python Tutorial 2: Circles and Rectangles
      • Python Tutorial 3: Arrows and Lines (and Poly Lines)
      • Python Tutorial 4: Simulating Change
      • Python Tutorial 5: Simulating Constant Velocity
      • Python Tutorial 6: Using Graphs
      • Python Tutorial 7: Modeling The Momentum Principle
      • Python Tutorial 8: Modeling A Projectile
      • Python Tutorial 9: Conditional Forces
    • Tutorials (MathJs)
      • MathJs Tutorial 1: Introduction to Coding in Tychos
      • MathJs Tutorial 2: Circles and Rectangles
      • MathJs Tutorial 3: Arrows and Lines
      • MathJs Tutorial 4: Simulating Change
      • MathJs Tutorial 5: Simulating Constant Velocity
      • MathJs Tutorial 6: Using Motion Graphs
      • MathJs Tutorial 7: Modeling The Momentum Principle
      • MathJs Tutorial 8: Modeling A Projectile
      • MathJs Tutorial 9: Conditional Forces
    • Writing Goals (Python)
    • Writing Goals (MathJs)
    • Canvas LTI Installation Guide
    • Lesson Worksheets (Google Docs)
Powered by GitBook
On this page

Was this helpful?

  1. For Teachers
  2. Tutorials (MathJs)

MathJs Tutorial 3: Arrows and Lines

This page is under construction, but will be completed soon.

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!

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 wil display the component vectors for the diagonal vector.

PreviousMathJs Tutorial 2: Circles and RectanglesNextMathJs Tutorial 4: Simulating Change

Last updated 1 year ago

Was this helpful?