randFromArray([[3, 4, 5], [6, 8, 10], [9, 12, 15], [5, 12, 13]])
randFromArray([[A, B], [B, A]])
18 - X_AXIS
18 - Y_AXIS
randRange(-MAX_X, MAX_X)
randRange(-MAX_Y, MAX_Y)
X_AXIS > Y_AXIS ? [H + C, K] : [H, K + C]
X_AXIS > Y_AXIS ? [H - C, K] : [H, K - C]
X_AXIS > Y_AXIS ? [[H, K - 1], [H, K + 1]] : [[H - 1, K], [H + 1, K]]
Find the foci of the ellipse below by moving the orange points to their correct positions.
graph.f1 = F1;
graph.f2 = F2;
DUMMY_GRAPH = graph;
initAutoscaledGraph([[-20, 20], [-20, 20]], {});
addMouseLayer();
graph.ellipse = interactiveEllipse({
center: [H, K],
xRadius: X_AXIS,
yRadius: Y_AXIS
});
graph.focus1 = addMovablePoint({
coordX: FOCUS_START[0][0],
coordY: FOCUS_START[0][1],
snapX: 1,
snapY: 1
});
graph.focus1.onMove = function(coordX, coordY) {
var x = $("#problemarea span.focus1-x-label")
$("#problemarea span.focus1-x-label").html("<code>" + coordX + "</code>").tex();
$("#problemarea span.focus1-y-label").html("<code>" + coordY + "</code>").tex();
};
graph.focus2 = addMovablePoint({
coordX: FOCUS_START[1][0],
coordY: FOCUS_START[1][1],
snapX: 1,
snapY: 1
});
graph.focus2.onMove = function(coordX, coordY) {
$("#problemarea span.focus2-x-label").html("<code>" + coordX + "</code>").tex();
$("#problemarea span.focus2-y-label").html("<code>" + coordY + "</code>").tex();
};
doEllipseInteraction(graph.ellipse, graph.focus1, graph.focus2);
var writeDistances = function(coordX, coordY) {
var focusDistance1 = KhanUtil.getDistance([coordX, coordY], graph.focus1.coord);
var focusDistance2 = KhanUtil.getDistance([coordX, coordY], graph.focus2.coord);
var distanceSum = focusDistance1 + focusDistance2;
$("#problemarea span.focus-distance1").html("<code>" + round(10 * focusDistance1) / 10 + "</code>").tex();
$("#problemarea span.focus-distance2").html("<code>" + round(10 * focusDistance2) / 10 + "</code>").tex();
$("#problemarea span.distance-difference").html("<code>" + round(10 * distanceSum) / 10 + "</code>").tex();
};
graph.ellipse.writeDistances = writeDistances;
[DUMMY_GRAPH.focus1.coord, DUMMY_GRAPH.focus2.coord]
if (_.isEqual(guess, FOCUS_START)) {
return "You need to move the foci to the correct positions.";
}
return (guess[0][0] === F1[0] && guess[0][1] === F1[1] &&
guess[1][0] === F2[0] && guess[1][1] === F2[1]) ||
(guess[0][0] === F2[0] && guess[0][1] === F2[1] &&
guess[1][0] === F1[0] && guess[1][1] === F1[1]);
graph.focus1.setCoord(guess[0]);
graph.focus2.setCoord(guess[1]);
Both foci must lie along the major axis of the ellipse.
if (X_AXIS > Y_AXIS) {
path([[H - X_AXIS, K], [H + X_AXIS, K]], { stroke: BLUE, strokeDasharray: "- " });
} else {
path([[H, K - Y_AXIS], [H, K + Y_AXIS]], { stroke: BLUE, strokeDasharray: "- " });
}
The foci must be equally distant from the center of the ellipse.
circle([H, K], 0.25, { stroke: BLUE, fill: BLUE });
We can adjust the positions of the foci along the major axis
until we've found the unique state where the sum of the distances is constant.
One focus is (F1[0], F1[1])
and the other is (F2[0], F2[1])
.
graph.focus1.moveTo(graph.f1[0], graph.f1[1]);
graph.focus2.moveTo(graph.f2[0], graph.f2[1]);