- Write a function in Desmos graphing calculator, such as y=cos(x).
- Demonstrate how to incorporate the function into a loop for contructing a block.
- Have students repeat the process and share their output in the class chat.
Example 1
for (x= [-50:.1:50]){
y=20*cos(18*x);
translate([x,y,0])cube([1,1,10]);
}
Example 2
a=20;
b=15;
c=5;
k=10;
d=0.1;
for (x= [-30:d:30]){
y = a*cos(b*x)+c;
translate([x,y,0])color("blue")cube([1,1,10]);
}
for (x= [-30:d:30]){
y = a*cos(b*(x+k))-c;
translate([x,y,0])color("yellow")cube([1,1,10]);
}
for (x= [-30:d:30]){
y = a*cos(b*x)-c;
translate([x,y,0])color("red")cube([1,1,10]);
}
for (x= [-30:d:30]){
y = a*cos(b*(x+k))+c;
translate([x,y,0])color("green")cube([1,1,10]);
}