// Numbas version: finer_feedback_settings {"name": "Terry's copy of Distance between two points", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"statement": "

Fill in the blanks.

", "ungrouped_variables": ["l", "xa1", "xa2", "ya1", "ya2", "dx", "dy", "x1", "y1", "x2", "y2", "triple"], "functions": {"diagram": {"definition": "var div = Numbas.extensions.jsxgraph.makeBoard('600px','600px',{boundingBox:[-13,13,13,-13],grid:true,axis:false});\nvar board = div.board;\n\n// create the x-axis.\nvar xaxis = board.create('line',[[0,0],[1,0]], { strokeColor: 'black', fixed: true});\nvar xticks = board.create('ticks',[xaxis,2],{\n drawLabels: true,\n label: {offset: [-4, -10]},\n minorTicks: 0\n});\n\n// create the y-axis\nvar yaxis = board.create('line',[[0,0],[0,1]], { strokeColor: 'black', fixed: true });\nvar yticks = board.create('ticks',[yaxis,2],{\ndrawLabels: true,\nlabel: {offset: [-20, 0]},\nminorTicks: 0\n});\n\n\nx0 = Numbas.jme.unwrapValue(scope.variables.xa1);\ny0 = Numbas.jme.unwrapValue(scope.variables.ya1);\nx1 = Numbas.jme.unwrapValue(scope.variables.xa2);\ny1 = Numbas.jme.unwrapValue(scope.variables.ya2);\n\nboard.create('point',[x0,y0],{fixed:true,withLabel:false});\nboard.create('point',[x1,y1],{fixed:true,withLabel:false});\n\nvar vline = board.create('line',[[x0,y0],[x0,y1]], {straightFirst:false, straightLast:false, strokeWidth:2, fixed:true});\nvar hline = board.create('line',[[x0,y1],[x1,y1]], {straightFirst:false, straightLast:false, strokeWidth:2, fixed:true});\nvar dia = board.create('line',[[x0,y0],[x1,y1]], {straightFirst:false, straightLast:false, strokeWidth:2, fixed:true});\n\nvar rise = board.create('text',[x0+0.25,(y0+y1)/2,'b']);\nvar run = board.create('text',[(x0+x1)/2,y1-0.5,'a']);\nvar hyp = board.create('text',[(x0+x1)/2,(y0+y1)/2+0.5,'c']);\n\nreturn div;\n", "language": "javascript", "type": "html", "parameters": []}}, "rulesets": {}, "parts": [{"marks": 0, "scripts": {}, "variableReplacementStrategy": "originalfirst", "prompt": "

The distance between the points $(\\var{x1},\\var{y1})$ and $(\\var{x2},\\var{y2})$ is  [[0]] units.

\n

\n

Note: For this question your answer should be an integer. 

", "variableReplacements": [], "gaps": [{"correctAnswerFraction": true, "notationStyles": ["plain", "en", "si-en"], "minValue": "triple[2]", "variableReplacements": [], "allowFractions": true, "showCorrectAnswer": true, "showFeedbackIcon": true, "marks": 1, "scripts": {}, "variableReplacementStrategy": "originalfirst", "maxValue": "triple[2]", "correctAnswerStyle": "plain", "type": "numberentry", "mustBeReducedPC": 0, "mustBeReduced": false}], "type": "gapfill", "showFeedbackIcon": true, "showCorrectAnswer": true}, {"marks": 0, "scripts": {}, "variableReplacementStrategy": "originalfirst", "prompt": "

The distance between the points $(\\var{xa1},\\var{ya1})$ and $(\\var{xa2},\\var{ya2})$ is  [[0]] units.

\n

\n

Note: For this question you can enter exact answers by using expressions such as sqrt(200) to indicate $\\sqrt{200}$. 

", "variableReplacements": [], "gaps": [{"vsetrangepoints": 5, "checkingtype": "absdiff", "variableReplacements": [], "vsetrange": [0, 1], "checkvariablenames": false, "showCorrectAnswer": true, "showFeedbackIcon": true, "marks": 1, "showpreview": true, "scripts": {}, "variableReplacementStrategy": "originalfirst", "answer": "sqrt({dx^2+dy^2})", "expectedvariablenames": [], "type": "jme", "checkingaccuracy": 0.001}], "type": "gapfill", "showFeedbackIcon": true, "showCorrectAnswer": true}], "name": "Terry's copy of Distance between two points", "preamble": {"js": "", "css": ""}, "advice": "

The distance between the points $(x_1,y_1)$ and $(x_2,y_2)$ is $\\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$ units. This is the simply the length of the hypotenuse of the right angled triangle given by Pythagoras' Theorem $c^2=a^2+b^2$. 

\n

{diagram()}

\n

a) For the points $(\\var{x1},\\var{y1})$ and $(\\var{x2},\\var{y2})$ this is a distance of

\n

$\\begin{align}\\sqrt{\\simplify[basic]{({x2}-{x1})^2+({y2}-{y1})^2}}&=\\sqrt{\\simplify[basic]{({x2-x1})^2+({y2-y1})^2}}\\\\&=\\sqrt{\\simplify[basic]{{(x2-x1)^2}+{(y2-y1)^2}}}\\\\&=\\sqrt{\\simplify[basic]{{(x2-x1)^2+(y2-y1)^2}}}\\\\&=\\var{triple[2]} \\quad \\text{units.}\\end{align}$

\n

\n

b) For the points $(\\var{xa1},\\var{ya1})$ and $(\\var{xa2},\\var{ya2})$ this is a distance of

\n

$\\begin{align}\\sqrt{\\simplify[basic]{({xa2}-{xa1})^2+({ya2}-{ya1})^2}}&=\\sqrt{\\simplify[basic]{({xa2-xa1})^2+({ya2-ya1})^2}}\\\\&=\\sqrt{\\simplify[basic]{{(xa2-xa1)^2}+{(ya2-ya1)^2}}}\\\\&=\\sqrt{\\simplify[basic]{{(xa2-xa1)^2+(ya2-ya1)^2}}} \\quad \\text{units.}\\end{align}$

\n

", "metadata": {"description": "

Calculate the midpoint of two points.

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "variable_groups": [], "tags": [], "variables": {"x1": {"definition": "l[4]", "description": "", "name": "x1", "group": "Ungrouped variables", "templateType": "anything"}, "l": {"definition": "shuffle(-12..12)[0..8]", "description": "

l

", "name": "l", "group": "Ungrouped variables", "templateType": "anything"}, "ya2": {"definition": "l[3]", "description": "", "name": "ya2", "group": "Ungrouped variables", "templateType": "anything"}, "ya1": {"definition": "l[2]", "description": "", "name": "ya1", "group": "Ungrouped variables", "templateType": "anything"}, "y2": {"definition": "y1+random([-1,1])*triple[1]", "description": "", "name": "y2", "group": "Ungrouped variables", "templateType": "anything"}, "triple": {"definition": "random([[3, 4, 5], [5, 12, 13], [7, 24, 25], [8, 15, 17], [9, 40, 41], [11, 60, 61], [12, 35, 37], [16, 63, 65], [20, 21, 29], [20, 99, 101]])", "description": "", "name": "triple", "group": "Ungrouped variables", "templateType": "anything"}, "y1": {"definition": "l[6]", "description": "", "name": "y1", "group": "Ungrouped variables", "templateType": "anything"}, "xa1": {"definition": "l[0]", "description": "", "name": "xa1", "group": "Ungrouped variables", "templateType": "anything"}, "dy": {"definition": "ya2-ya1", "description": "", "name": "dy", "group": "Ungrouped variables", "templateType": "anything"}, "x2": {"definition": "x1+random([-1,1])*triple[0]", "description": "", "name": "x2", "group": "Ungrouped variables", "templateType": "anything"}, "dx": {"definition": "xa2-xa1", "description": "", "name": "dx", "group": "Ungrouped variables", "templateType": "anything"}, "xa2": {"definition": "l[1]", "description": "

xa

", "name": "xa2", "group": "Ungrouped variables", "templateType": "anything"}}, "variablesTest": {"maxRuns": 100, "condition": ""}, "extensions": ["jsxgraph"], "type": "question", "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}, {"name": "Terry Young", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3130/"}]}]}], "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}, {"name": "Terry Young", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3130/"}]}