Draw a parabola using a pen attached to a robot

From wikiluntti
Revision as of 18:51, 16 October 2020 by Mol (talk | contribs) (→‎Exercises)

Introduction

How to use robot to draw mathematical shapes? We start by doing a parabola.

Aim

Triangles, trigonometric functions, Pythagorean theorem, series, limit, differential.

Center of gravity

Robot

Almost any robot will do, but this example is done using Asimov 2/ Verne. Note that some exercises requires a different robot.

Sensors

A gyroscope sensor is used in addition to servo motors.

Example Video

Theory

The robot follows the blue line.

A parabola is a function (or mapping) (without the constant). The inverse function of the positive root is . We drive the robot in steps to the vertex, see the image.

The angle of th slope with respect to the resetting can calculated using function. The distance travelled by the robot can be obtained using trigonometric functions or Pythagorean theorem.


Note that all parabolas are similar, see is only One True Parabola by Matt Parker


Python

The code should be tested on a computer first.

import matplotlib.pyplot as plt
import math

a = -5
x,y = [], []
for i in range(-5,1):
    y1 = i
    y0 = i-1
    Dy = y1-y0
    Dx = math.sqrt(y1/a) - math.sqrt(y0/a)
    alpha = math.atan(Dx/Dy)/3.14159*180    #In degrees
    l = math.sqrt(Dy**2 + Dx**2)
    print( alpha, l )
    x.append( math.sqrt(y1/a) )
    y.append( y1 )
        
# Plot the true parabola using Numpy.
from numpy import *
xx=linspace(0,x[1],5000)
yy=a*xx**2

plt.plot(x,y, 'o-')
plt.plot(xx,yy)

Example Code

Exercises

  • Use more points than those provided here.
  • Implement proportional gyroscope follower so that the robot follows the correct angle even if the robot is disturbed.
  • Apply trigonometric functions to calculate .
  • Notice that the position of pen is not optimal. Where should the pen be located? Modify the robot such that you can put the pen into an optimal position.
  • Make the parabola symmetric, thus make the robot turn more.
  • Instead of using triangles, try making a limit and using the differential of the curve.
  • Apply the method to draw 3th and 4th order polynomials, too.


Back to Mahtavaa Matematiikkaa 2020