randRange(1, 8)
randRange(1, 8)
randRangeExclude(1, 5, [X1])
randRangeExclude(1, 5, [Y1])
(Y1 - Y2) / (X1 - X2)
fractionReduce(Y1 - Y2, X1 - X2)
SLOPE * X1 - Y1
Die beiden Punkte ({\color{blue}X1}, {\color{blue}Y1})
und ({\color{red}X2}, {\color{red}Y2})
liegen auf einer Geraden
y = f(x)
. Dann gilt:
[$("input#response1").val(), $("input#response2").val(), $("input#response3").val()]
var xyMessage = null, xyEmpty = false;
var slopeValidator = Khan.answerTypes.predicate.createValidatorFunctional(function(slope, error) {
if (Math.abs(slope - SLOPE) > Math.pow(2, -42)) {
return false;
}
var yMessage = null, yEmpty = false;
var xValidator = Khan.answerTypes.predicate.createValidatorFunctional(function(x, error) {
var yValidator = Khan.answerTypes.predicate.createValidatorFunctional(function(y, error) {
return Math.abs((x * slope - y) - INTERCEPT) < Math.pow(2, -42);
}, {forms: 'integer, proper, improper, mixed, decimal'});
var yResult = yValidator(guess[0]);
if (yResult.empty) {
yEmpty = true;
}
if (yResult.message !== null) {
yMessage = yResult.message;
}
if (yResult.correct) {
yEmpty = false;
yMessage = null;
}
return yResult.correct;
}, {forms: 'integer, proper, improper, mixed, decimal'});
var xResult = xValidator(guess[2]);
if (xResult.empty || yEmpty) {
xyEmpty = true;
}
if (xResult.message !== null || yMessage !== null) {
xyMessage = xResult.message || yMessage;
}
if (xResult.correct) {
xyEmpty = false;
xyMessage = null;
}
return xResult.correct;
}, {forms: 'integer, proper, improper, mixed, decimal, coefficient', fallback: 1});
var slopeResult = slopeValidator(guess[1]);
if (slopeResult.empty || xyEmpty) {
return "";
} else if (slopeResult.message !== null) {
return slopeResult.message;
} else if (xyMessage !== null) {
return xyMessage;
}
return slopeResult.correct;
Die Steigung der Geraden ist m = \dfrac{(y_{1} - y_{2})}{(x_{1} - x_{2})}
.
Eingesetzt ist dies
\dfrac{{\color{blue}Y1} - negParens(Y2, "red")}
{{\color{blue}X1} - negParens(X2, "red")} =
{\color{teal}\dfrac{Y1 - Y2}{X1 - X2}} =
{\color{teal}SLOPE_FRACTION}
Setze nun die Koordinaten x_{1}, y_{1}
eines Punktes ein.
Entweder (y - {\color{blue}Y1}) =
{\color{teal}SLOPE_FRACTION}(x - {\color{blue}X1})
,
oder (y - {\color{red}Y2}) = {\color{teal}SLOPE_FRACTION}(x -
{\color{red}X2})
.