Where is NUMBER
on the number line?
var scale = 40 / SCALE;
init({
range: [[LOWER_BOUND - (30 / scale), UPPER_BOUND + (30 / scale)], [-1, 1]],
scale: [40 / SCALE, 40]
});
line([LOWER_BOUND - (25 / scale), 0], [UPPER_BOUND + (25 / scale), 0], { arrows: "->" });
line([UPPER_BOUND + (25 / scale), 0], [LOWER_BOUND - (25 / scale), 0], { arrows: "->" });
for (var x = LOWER_BOUND; x <= UPPER_BOUND; x += SCALE) {
line([x, -0.2], [x, 0.2 ]);
}
style({ stroke: BLUE, strokeWidth: 3.5 });
line( [ 0, -0.2], [0, 0.2]);
label( [ 0, -0.53 ], "0", "center");
label( [ SCALE, -0.53 ], SCALE, "center");
addMouseLayer();
var snap = SCALE / 4;
if (SCALE === 3) {
snap = SCALE / 3;
}
graph.movablePoint = addMovablePoint({ constraints: { constrainY: true }, snapX: snap });
graph.movablePoint.onMove = function( x, y ) {
return [ min( max( LOWER_BOUND, x ), UPPER_BOUND ), y ];
};
Move the orange dot to select your answer.
graph.movablePoint.coord[0]
if (guess === 0) {
return "";
}
return abs(NUMBER - guess) < 0.001;
graph.movablePoint.setCoord([guess, 0]);
We know each tick mark is SCALE
because 0
and SCALE
are labeled.
Label the rest of the number line.
for (var x = LOWER_BOUND + 2 * SCALE; x <= UPPER_BOUND; x += SCALE) {
if (x !== NUMBER) {
label([x, -0.53], x, "center");
} else {
graph.num = label([x, -0.53], x, "center");
}
}
The orange number shows where NUMBER
is on the number line.
graph.num.remove();
label([ NUMBER, -0.53], NUMBER, "center", { color: ORANGE });
graph.movablePoint.moveTo(NUMBER, 0);