Contact Us!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Avatar for stephanie's main branch.

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Views: 59
Image: ubuntu2204
1
#This is the code for my toy b-robot Artie to "dance"/draw an infinity loop under the table
2
#include <iostream>
3
#include <artie>
4
Artie artie;
5
void draw_arc(char *direction, float fraction, float radius) {
6
float L = 78;
7
float PI = 3.141592;
8
float distance = PI * 2.0 * radius * fraction;
9
float angle = atan(L/radius) * 180/PI;
10
if (direction == 'left'){
11
angle = -angle;
12
}
13
artie.movearc(distance, angle); }
14
int main() {
15
artie.pendown(1);
16
artie.left(90);
17
draw_arc('right', (1.0/2.0), 50.0);
18
artie.right(1);
19
artie.pendown(2);
20
draw_arc('right', (73.0/360.0), 69.0);
21
artie.right(1);
22
draw_arc('left', (73.0/360.0), 69.0);
23
artie.left(1);
24
artie.pendown(3);
25
draw_arc('left', (1.0/2.0), 50.0);
26
artie.left(1);
27
artie.pendown(2)
28
draw_arc('left', (73.0/360.0), 69.0);
29
artie.left(1);
30
draw_arc('right', (73.0/360.0), 69.0);
31
return 0; }
32