// Numbas version: exam_results_page_options {"name": "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": [{"name": "Distance between two points", "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()}
\na) 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\nb) 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", "variable_groups": [], "ungrouped_variables": ["l", "xa1", "xa2", "ya1", "ya2", "dx", "dy", "x1", "y1", "x2", "y2", "triple"], "functions": {"diagram": {"language": "javascript", "parameters": [], "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", "type": "html"}}, "extensions": ["jsxgraph"], "variablesTest": {"condition": "", "maxRuns": 100}, "type": "question", "statement": "Fill in the blanks.
", "preamble": {"js": "", "css": ""}, "tags": [], "parts": [{"showFeedbackIcon": true, "marks": 0, "scripts": {}, "prompt": "The distance between the points $(\\var{x1},\\var{y1})$ and $(\\var{x2},\\var{y2})$ is [[0]] units.
\n\nNote: For this question your answer should be an integer.
", "type": "gapfill", "gaps": [{"correctAnswerStyle": "plain", "scripts": {}, "maxValue": "triple[2]", "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": true, "notationStyles": ["plain", "en", "si-en"], "marks": 1, "minValue": "triple[2]", "allowFractions": true, "correctAnswerFraction": true, "variableReplacements": [], "mustBeReduced": false}], "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": []}, {"showFeedbackIcon": true, "marks": 0, "scripts": {}, "prompt": "The distance between the points $(\\var{xa1},\\var{ya1})$ and $(\\var{xa2},\\var{ya2})$ is [[0]] units.
\n\nNote: For this question you can enter exact answers by using expressions such as sqrt(200) to indicate $\\sqrt{200}$.
", "type": "gapfill", "gaps": [{"scripts": {}, "checkingtype": "absdiff", "showpreview": true, "vsetrange": [0, 1], "vsetrangepoints": 5, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "jme", "showFeedbackIcon": true, "checkvariablenames": false, "marks": 1, "answer": "sqrt({dx^2+dy^2})", "checkingaccuracy": 0.001, "variableReplacements": [], "expectedvariablenames": []}], "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": []}], "rulesets": {}, "metadata": {"description": "Calculate the midpoint of two points.
", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "variables": {"y2": {"templateType": "anything", "definition": "y1+random([-1,1])*triple[1]", "description": "", "group": "Ungrouped variables", "name": "y2"}, "ya2": {"templateType": "anything", "definition": "l[3]", "description": "", "group": "Ungrouped variables", "name": "ya2"}, "x2": {"templateType": "anything", "definition": "x1+random([-1,1])*triple[0]", "description": "", "group": "Ungrouped variables", "name": "x2"}, "y1": {"templateType": "anything", "definition": "l[6]", "description": "", "group": "Ungrouped variables", "name": "y1"}, "x1": {"templateType": "anything", "definition": "l[4]", "description": "", "group": "Ungrouped variables", "name": "x1"}, "triple": {"templateType": "anything", "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": "", "group": "Ungrouped variables", "name": "triple"}, "xa2": {"templateType": "anything", "definition": "l[1]", "description": "xa
", "group": "Ungrouped variables", "name": "xa2"}, "ya1": {"templateType": "anything", "definition": "l[2]", "description": "", "group": "Ungrouped variables", "name": "ya1"}, "dx": {"templateType": "anything", "definition": "xa2-xa1", "description": "", "group": "Ungrouped variables", "name": "dx"}, "xa1": {"templateType": "anything", "definition": "l[0]", "description": "", "group": "Ungrouped variables", "name": "xa1"}, "l": {"templateType": "anything", "definition": "shuffle(-12..12)[0..8]", "description": "l
", "group": "Ungrouped variables", "name": "l"}, "dy": {"templateType": "anything", "definition": "ya2-ya1", "description": "", "group": "Ungrouped variables", "name": "dy"}}, "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}]}], "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}