// Numbas version: exam_results_page_options {"name": "Trigonometry Cosine rule", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Trigonometry Cosine rule", "advice": "

Use the cosine rule to find the angles.

\n

\"Image

", "variable_groups": [{"variables": [], "name": "Unnamed group"}], "ungrouped_variables": ["unitList", "units", "a", "angleARough", "asinA", "angleMin", "angleBmax", "bMax", "bMin", "b", "angleBRough", "angleCRough", "c", "angleA", "angleB", "angleC"], "functions": {"plotgraph": {"language": "javascript", "parameters": [["units", "string"], ["a", "number"], ["b", "number"], ["c", "number"], ["angleA", "number"], ["angleB", "number"], ["angleC", "number"]], "definition": "// This functions plots a triangle based on three lengths\n\n//Function ot convert angles to radians\nfunction toRadians (angle) {\n return angle * (Math.PI / 180);\n}\n\n//Calculate height of triangle\nvar h = b*Math.sin(toRadians(angleC))\n\n//Set text and graph offsets to appear uniform\nvar xOffset = Math.ceil(a/10)\nvar yOffset = Math.ceil(a/2+xOffset-h/2)\n//Consider removing scale once all adjusted correctly\nvar offset = 1;\nvar textHeight =15;\nvar scale = xOffset/2;\nvar scaleOffset = offset*scale;\nvar scaleText = textHeight*scale;\n// This functions plots two dimensioned lines \n// Max and min x and y values for the axis.\nvar x_min = 0;\nvar x_max = a+2*xOffset;\nvar y_min = 0;\nvar y_max = a+2*xOffset;\n\n//Browser compatibility\nJXG.Options.text.display = 'internal';\n//Use MathJax for LaTeX display\nJXG.Options.text.useMathJax = true;\n\n// Make the JSXGraph board.\nvar div = Numbas.extensions.jsxgraph.makeBoard(\n '500px',\n '500px',\n {\n boundingBox: [0,y_max,x_max,0],\n//Change to false after testing\n axis: false,\n }\n);\n\n// div.board is the object created by JSXGraph, which you use to manipulate elements\nvar board = div.board; \n\n/*\n//Dummy text for testing variables, remove after testing\ntempText = board.create('text',[(xOffset),(h+yOffset*1.5),\nfunction () {return 'A is ' + angleA.toFixed(4) + ' B is ' + angleB.toFixed(4) + ' C is ' + angleC.toFixed(4)}]);\ntempText2 = board.create('text',[(xOffset),(yOffset/2),\nfunction () {return 'a is ' + a + ' b is ' + b + ' c is ' + c}]);\n*/\n\n//Draw three points \nvar pA = board.create('point', [(b*Math.cos(toRadians(angleC))+xOffset), (b*Math.sin(toRadians(angleC))+yOffset)], \n//Make fixed:true after testing\n {size:0, fixed:true,\n label:{offset: [0,10]}});\nvar pB = board.create('point', [(a+xOffset), (yOffset)],\n {size:0, fixed:true,\n label:{offset: [10,-10]}});\nvar pC = board.create('point', [(xOffset), (yOffset)],\n {size:0, fixed:true,\n label:{offset: [-10,-10]}});\n\n//Draw a line between them\nvar AB = board.create('line',[pA,pB],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\nvar BC = board.create('line',[pC,pB],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\nvar AC = board.create('line',[pC,pA],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\n\n//Draw angles\nvar ABC = board.create('nonreflexangle', [pA,pB,pC], {type:'sector', orthoType:'square', orthoSensitivity:0.4, \nradius:function() { return scale;}\n });\nvar CAB = board.create('nonreflexangle', [pC,pA,pB], {type:'sector', orthoType:'square', orthoSensitivity:0.4,\nradius:function() { return scale;} \n});\nvar BCA = board.create('nonreflexangle', [pB,pC,pA], {type:'sector', orthoType:'square', orthoSensitivity:0.4,\nradius:function() { return scale;} \n});\n\n//Blank out label for this version\nABC.label.setText('');\nCAB.label.setText('');\nBCA.label.setText('');\n\n/* Angle labels used for testing\nvar ABCLabel = ABC.label.setText(function () {\n var angle = 180.0 * ABC.Value() / Math.PI;\n if ((angle > 90.4) || (angle < 89.6)) {\n return ''+angle.toFixed(2) + '\\u00B0';\n } else {\n return '';\n }\n});\nABCLabel.setAttribute({anchorX:'middle'});\n\nvar CABLabel = CAB.label.setText(function () {\n var angle = 180.0 * CAB.Value() / Math.PI;\n if ((angle > 90.4) || (angle < 89.6)) {\n return ''+angle.toFixed(2) + '\\u00B0';\n } else {\n return '';\n }\n});\nCABLabel.setAttribute({anchorX:'middle'});\n\nvar BCALabel = BCA.label.setText(function () {\n var angle = 180.0 * BCA.Value() / Math.PI;\n if ((angle > 90.4) || (angle < 89.6)) {\n return ''+angle.toFixed(2) + '\\u00B0';\n } else {\n return '';\n }\n});\nBCALabel.setAttribute({anchorX:'middle'});\n*/\n\n//Set up dimension labels to be properly aligned\ntextAB = board.create('text', \n [function () {return (pA.X() + pB.X())/2},\n function () {return ((pA.Y() + pB.Y())/2)+(scaleOffset/2)},\n function () {return +pA.Dist(pB).toFixed(2) + ' ' + units}],\n {fontSize:15, anchorX:'middle'});\n\ntextBC = board.create('text', \n [function () {return (pB.X() + pC.X())/2},\n function () {return ((pB.Y() + pC.Y())/2)-scaleOffset},\n function () {return +pB.Dist(pC).toFixed(0) + ' ' + units}],\n {fontSize:15, anchorX:'middle'});\n\ntextAC = board.create('text', \n [function () {return (pA.X() + pC.X())/2},\n function () {return ((pA.Y() + pC.Y())/2)+(scaleOffset/2)},\n function () {return +pA.Dist(pC).toFixed(2) + ' ' + units}],\n {fontSize:15, anchorX:'middle'});\n\n//Set up transform for rotating dimension labels\nvar tABRot = board.create('transform', \n [function () {return AB.getAngle()}, \n function () {return (pA.X() + pB.X())/2}, \n function () {return (pA.Y() + pB.Y())/2}],\n {type:'rotate'});\n\nvar tBCRot = board.create('transform', \n [function () {return BC.getAngle()}, \n function () {return (pB.X() + pC.X())/2}, \n function () {return (pB.Y() + pC.Y())/2}],\n {type:'rotate'});\n\n\nvar tACRot = board.create('transform', \n [function () {return AC.getAngle()}, \n function () {return (pA.X() + pC.X())/2}, \n function () {return (pA.Y() + pC.Y())/2}],\n {type:'rotate'});\n\n//Perform text rotations and update\ntABRot.bindTo(textAB);\ntBCRot.bindTo(textBC); \ntACRot.bindTo(textAC);\nboard.update();\n\nreturn div;", "type": "html"}}, "extensions": ["jsxgraph"], "variablesTest": {"condition": "b-c<>0 &&\na-c>0", "maxRuns": "200"}, "type": "question", "statement": "", "preamble": {"js": "", "css": ""}, "tags": [], "parts": [{"customMarkingAlgorithm": "", "sortAnswers": false, "scripts": {}, "prompt": "

{plotgraph(units,a,b,c,angleA,angleB,angleC)}

\n

What are the angles A, B and C?

\n

A = [[0]] $^{\\circ}$

\n

B = [[1]] $^{\\circ}$

\n

C = [[2]] $^{\\circ}$

\n

", "extendBaseMarkingAlgorithm": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "gapfill", "showFeedbackIcon": true, "marks": 0, "unitTests": [], "gaps": [{"customMarkingAlgorithm": "", "correctAnswerStyle": "plain", "scripts": {}, "maxValue": "{angleA}*1.01", "mustBeReducedPC": 0, "extendBaseMarkingAlgorithm": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": false, "notationStyles": ["plain", "en", "si-en"], "marks": "2", "allowFractions": false, "minValue": "{angleA}*0.99", "unitTests": [], "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}, {"customMarkingAlgorithm": "", "correctAnswerStyle": "plain", "scripts": {}, "maxValue": "{angleB}*1.01", "mustBeReducedPC": 0, "extendBaseMarkingAlgorithm": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": false, "notationStyles": ["plain", "en", "si-en"], "marks": "2", "allowFractions": false, "minValue": "{angleB}*0.99", "unitTests": [], "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}, {"customMarkingAlgorithm": "", "correctAnswerStyle": "plain", "scripts": {}, "maxValue": "{angleC}*1.01", "mustBeReducedPC": 0, "extendBaseMarkingAlgorithm": true, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": false, "notationStyles": ["plain", "en", "si-en"], "marks": "2", "allowFractions": false, "minValue": "{angleC}*0.99", "unitTests": [], "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}], "variableReplacements": []}], "rulesets": {}, "metadata": {"description": "

Draws a triangle based on 3 side lengths.

", "licence": "Creative Commons Attribution 4.0 International"}, "variables": {"angleMin": {"templateType": "anything", "definition": "30\n", "description": "", "group": "Ungrouped variables", "name": "angleMin"}, "angleBRough": {"templateType": "anything", "definition": "180*arcsin(b/asinA)/PI", "description": "

angle

", "group": "Ungrouped variables", "name": "angleBRough"}, "angleA": {"templateType": "anything", "definition": "180*arccos((b^2+c^2-a^2)/(2*b*c))/PI\n", "description": "", "group": "Ungrouped variables", "name": "angleA"}, "angleCRough": {"templateType": "anything", "definition": "180-(angleARough+angleBRough)", "description": "", "group": "Ungrouped variables", "name": "angleCRough"}, "angleB": {"templateType": "anything", "definition": "180*arccos((a^2+c^2-b^2)/(2*a*c))/PI\n", "description": "

angleB

", "group": "Ungrouped variables", "name": "angleB"}, "angleC": {"templateType": "anything", "definition": "180-(angleA + angleB)", "description": "", "group": "Ungrouped variables", "name": "angleC"}, "angleBmax": {"templateType": "anything", "definition": "150-angleARough", "description": "", "group": "Ungrouped variables", "name": "angleBmax"}, "c": {"templateType": "anything", "definition": "precround(((a^2+b^2-2*a*b*cos(radians(angleCRough)))^0.5),0)", "description": "", "group": "Ungrouped variables", "name": "c"}, "b": {"templateType": "anything", "definition": "random(floor(bMin)..floor(bMax) except a)", "description": "", "group": "Ungrouped variables", "name": "b"}, "bMax": {"templateType": "anything", "definition": "asinA*sin(radians(angleBmax))", "description": "", "group": "Ungrouped variables", "name": "bMax"}, "a": {"templateType": "anything", "definition": "random(5..50)", "description": "", "group": "Ungrouped variables", "name": "a"}, "units": {"templateType": "anything", "definition": "random(unitList)", "description": "", "group": "Ungrouped variables", "name": "units"}, "unitList": {"templateType": "list of strings", "definition": "[ \"mm\", \"cm\", \"m\", \"km\" ]", "description": "

Units that are to be used for the question.

", "group": "Ungrouped variables", "name": "unitList"}, "asinA": {"templateType": "anything", "definition": "a/(sin(radians(angleARough)))\n", "description": "", "group": "Ungrouped variables", "name": "asinA"}, "bMin": {"templateType": "anything", "definition": "asinA*sin(radians(angleMin))", "description": "", "group": "Ungrouped variables", "name": "bMin"}, "angleARough": {"templateType": "anything", "definition": "random(75..120 except 89 except 90 except 91)", "description": "

Temp

", "group": "Ungrouped variables", "name": "angleARough"}}, "contributors": [{"name": "Angharad Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/315/"}, {"name": "Mark Hodds", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/510/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}]}], "contributors": [{"name": "Angharad Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/315/"}, {"name": "Mark Hodds", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/510/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}