// Numbas version: exam_results_page_options {"name": "Trigonometry Application", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [{"name": "Unnamed group", "variables": []}], "rulesets": {}, "name": "Trigonometry Application", "extensions": ["jsxgraph"], "statement": "

The figure below shows the position of four towns marked on a map.

\n

{plotgraph(WY,WX,XY,WZ,WXY,XYW,XWY,theta)}

", "variables": {"WY": {"name": "WY", "templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "sqrt(WX^2+XY^2)"}, "theta": {"name": "theta", "templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "degrees(arccos(WZ/WY))"}, "YZ": {"name": "YZ", "templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "sqrt(WY^2-WZ^2)"}, "XWY": {"name": "XWY", "templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "180-(WXY + XYW)"}, "WZmax": {"name": "WZmax", "templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "ceil(WY*sqrt(0.75))"}, "XYW": {"name": "XYW", "templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "random(30..60)"}, "WZmin": {"name": "WZmin", "templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "floor(WY/2)"}, "WZ": {"name": "WZ", "templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "random(WZmin..WZmax)"}, "XY": {"name": "XY", "templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "WX/(tan(radians(XYW)))"}, "WXY": {"name": "WXY", "templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "90\n"}, "WX": {"name": "WX", "templateType": "anything", "description": "", "group": "Ungrouped variables", "definition": "random(5..50)"}}, "parts": [{"showCorrectAnswer": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "prompt": "

Calculate, to the nearest kilometre, the distance between towns W and Y

\n

WY = [[0]] km

", "showFeedbackIcon": true, "type": "gapfill", "gaps": [{"showCorrectAnswer": true, "variableReplacements": [], "showPrecisionHint": false, "variableReplacementStrategy": "originalfirst", "precisionMessage": "You have not given your answer to the correct precision.", "mustBeReducedPC": 0, "precisionType": "dp", "scripts": {}, "minValue": "{WY}", "allowFractions": false, "showFeedbackIcon": true, "precision": "0", "strictPrecision": false, "marks": "1", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "correctAnswerStyle": "plain", "precisionPartialCredit": "50", "maxValue": "{WY}", "mustBeReduced": false}], "scripts": {}}, {"showCorrectAnswer": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "prompt": "

Calculate, to the nearest degree, the size of the angle marked $\\theta$.

\n

$\\theta$ = [[0]] $^\\circ$

", "showFeedbackIcon": true, "type": "gapfill", "gaps": [{"showCorrectAnswer": true, "variableReplacements": [], "showPrecisionHint": false, "variableReplacementStrategy": "originalfirst", "precisionMessage": "You have not given your answer to the correct precision.", "mustBeReducedPC": 0, "precisionType": "dp", "scripts": {}, "minValue": "{theta}", "allowFractions": false, "showFeedbackIcon": true, "precision": 0, "strictPrecision": false, "marks": 1, "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "correctAnswerStyle": "plain", "precisionPartialCredit": "50", "maxValue": "{theta}", "mustBeReduced": false}], "scripts": {}}, {"showCorrectAnswer": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "prompt": "

Calculate to the neraest kilometre, the distance between towns Y and Z.

\n

YZ = [[0]] km

", "showFeedbackIcon": true, "type": "gapfill", "gaps": [{"showCorrectAnswer": true, "variableReplacements": [], "showPrecisionHint": false, "variableReplacementStrategy": "originalfirst", "precisionMessage": "You have not given your answer to the correct precision.", "mustBeReducedPC": 0, "precisionType": "dp", "scripts": {}, "minValue": "{YZ}", "allowFractions": false, "showFeedbackIcon": true, "precision": 0, "strictPrecision": false, "marks": 1, "correctAnswerFraction": false, "notationStyles": ["en", "si-en"], "type": "numberentry", "correctAnswerStyle": "en", "precisionPartialCredit": "50", "maxValue": "{YZ}", "mustBeReduced": false}], "scripts": {}}], "ungrouped_variables": ["WXY", "XYW", "XWY", "WX", "XY", "WY", "WZmin", "WZmax", "WZ", "YZ", "theta"], "preamble": {"js": "", "css": ""}, "variablesTest": {"condition": "WX-XY<>0 &&\nWY-XY>0", "maxRuns": "200"}, "functions": {"plotgraph": {"parameters": [["WY", "number"], ["WX", "number"], ["XY", "number"], ["WZ", "number"], ["WXY", "number"], ["XYW", "number"], ["XWY", "number"], ["theta", "number"]], "type": "html", "language": "javascript", "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 hX = WX*Math.sin(toRadians(XWY))\nvar hZ = WZ*math.sin(toRadians(theta))\nvar h = Math.max(hX, hZ);\n\n//Set text and graph offsets to appear uniform\nvar xOffset = Math.ceil(WY/10)\nvar yOffset = Math.ceil(WY/2+xOffset-(hX+hZ)/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 = WY+2*xOffset;\nvar y_max = x_max/2;\nvar y_min = -y_max;\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,y_min],\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//Draw three points \nvar pX = board.create('point', [(WX*Math.cos(toRadians(XWY))+xOffset), (WX*Math.sin(toRadians(XWY)))], \n {size:0, fixed:true, name:'X',\n label:{offset: [-5,10]}});\nvar pY = board.create('point', [(WY+xOffset), (0)],\n {size:0, fixed:true, name:'Y',\n label:{offset: [20,0]}});\nvar pW = board.create('point', [(xOffset), (0)],\n {size:0, fixed:true, name:'W',\n label:{offset: [-20,0]}});\nvar pZ = board.create('point', [(WZ*Math.cos(toRadians(theta))+xOffset), (-WZ*Math.sin(toRadians(theta)))],\n {size:0, fixed:true, name:'Z',\n label:{offset: [-5,-20]}});\n\n//Dummy text for testing variables, remove after testing\n//tempText = board.create('text',[(xOffset),(hX+yOffset),\n//function () {return 'hX is ' + hX.toFixed(2) + ' hZ is ' + hZ.toFixed(2) + ' h is ' + h.toFixed(2) + ' x_max is ' + x_max.toFixed(2) + ' y_max is ' + y_max.toFixed(2)}]);\ntempText = board.create('text',[(xOffset),(hX+yOffset/2),\nfunction () {return 'Theta is ' + theta.toFixed(2)}]);\ntempText2 = board.create('text',[(xOffset),(-hZ-yOffset/2),\nfunction () {return 'WY is ' + WY.toFixed(2) + ' ZY is ' + +pY.Dist(pZ).toFixed(2)}]);\n\n//Draw a line between them\nvar lXY = board.create('line',[pX,pY],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\nvar lWY = board.create('line',[pW,pY],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\nvar lWX = board.create('line',[pW,pX],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\nvar lWZ = board.create('line',[pW,pZ],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\nvar lZY = board.create('line',[pZ,pY],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\n\n//Draw angles\nvar angleXYW = board.create('nonreflexangle', [pX,pY,pW], {type:'sector', orthoType:'square', orthoSensitivity:0.4, \nradius:function() { return scale;}\n });\nvar angleWXY = board.create('nonreflexangle', [pW,pX,pY], {type:'sector', orthoType:'square', orthoSensitivity:0.4,\nradius:function() { return scale;} \n});\n/*\nvar angleXWY = board.create('nonreflexangle', [pY,pW,pX], {type:'sector', orthoType:'square', orthoSensitivity:0.4,\nradius:function() { return scale;} \n});\n*/\nvar angleYWZ = board.create('nonreflexangle', [pY,pW,pZ], {type:'sector', orthoType:'square', orthoSensitivity:0.4,\nradius:function() { return scale;} \n});\n\nvar angleWZY = board.create('nonreflexangle', [pW,pZ,pY], {type:'sector', orthoType:'square', orthoSensitivity:0.4,\nradius:function() { return scale;} \n});\n\n\n//Blank out label for this version\nangleXYW.label.setText('');\nangleWXY.label.setText('');\n//angleXWY.label.setText('');\nangleYWZ.label.setText('\\u03B8');\nangleWZY.label.setText('');\n\nvar XYWLabel = angleXYW.label.setText(function () {\n var angle = 180.0 * angleXYW.Value() / Math.PI;\n if ((angle > 90.4) || (angle < 89.6)) {\n return ''+angle.toFixed(0) + '\\u00B0';\n } else {\n return '';\n }\n});\nXYWLabel.setAttribute({anchorX:'middle'});\n\n/* Angle labels used for testing\nvar WXYLabel = angleWXY.label.setText(function () {\n var angle = 180.0 * angleWXY.Value() / Math.PI;\n if ((angle > 90.4) || (angle < 89.6)) {\n return ''+angle.toFixed(2) + '\\u00B0';\n } else {\n return '';\n }\n});\nWXYLabel.setAttribute({anchorX:'middle'});\n\nvar XWYLabel = angleXWY.label.setText(function () {\n var angle = 180.0 * angleXWY.Value() / Math.PI;\n if ((angle > 90.4) || (angle < 89.6)) {\n return ''+angle.toFixed(2) + '\\u00B0';\n } else {\n return '';\n }\n});\nXWYLabel.setAttribute({anchorX:'middle'});\n*/\n\n//Set up dimension labels to be properly aligned\n/*\ntextXY = board.create('text', \n [function () {return (pX.X() + pY.X())/2},\n function () {return ((pX.Y() + pY.Y())/2)+(scaleOffset/2)},\n function () {return +pX.Dist(pY).toFixed(2) + 'km'}],\n {fontSize:15, anchorX:'middle'});\n*/\n\ntextWY = board.create('text', \n [function () {return (pY.X() + pW.X())/2},\n function () {return ((pY.Y() + pW.Y())/2)-scaleOffset/2},\n function () {return '? km'}],\n {fontSize:15, anchorX:'middle'});\n\ntextWX = board.create('text', \n [function () {return (pX.X() + pW.X())/2},\n function () {return ((pX.Y() + pW.Y())/2)+(scaleOffset/2)},\n function () {return +pX.Dist(pW).toFixed(2) + 'km'}],\n {fontSize:15, anchorX:'middle'});\n\ntextWZ = board.create('text', \n [function () {return (pW.X() + pZ.X())/2},\n function () {return ((pZ.Y())/2)+(scaleOffset/2)},\n function () {return +pW.Dist(pZ).toFixed(2) + 'km'}],\n {fontSize:15, anchorX:'middle'});\n\ntextZY = board.create('text', \n [function () {return (pY.X() + pZ.X())/2},\n function () {return ((pZ.Y())/2)+(scaleOffset/2)},\n function () {return '? km'}],\n {fontSize:15, anchorX:'middle'});\n\n//Set up transform for rotating dimension labels\n/*\nvar tXYRot = board.create('transform', \n [function () {return lXY.getAngle()}, \n function () {return (pX.X() + pY.X())/2}, \n function () {return (pX.Y() + pY.Y())/2}],\n {type:'rotate'});\n*/\n\nvar tWYRot = board.create('transform', \n [function () {return lWY.getAngle()}, \n function () {return (pY.X() + pW.X())/2}, \n function () {return (pY.Y() + pW.Y())/2}],\n {type:'rotate'});\n\nvar tWXRot = board.create('transform', \n [function () {return lWX.getAngle()}, \n function () {return (pX.X() + pW.X())/2}, \n function () {return (pX.Y() + pW.Y())/2}],\n {type:'rotate'});\n\nvar tWZRot = board.create('transform', \n [function () {return lWZ.getAngle()}, \n function () {return (pW.X() + pZ.X())/2}, \n function () {return (pZ.Y())/2}],\n {type:'rotate'});\n\nvar tZYRot = board.create('transform', \n [function () {return lZY.getAngle()}, \n function () {return (pY.X() + pZ.X())/2}, \n function () {return (pZ.Y())/2}],\n {type:'rotate'});\n\n//Perform text rotations and update\n//tXYRot.bindTo(textXY);\ntWYRot.bindTo(textWY); \ntWXRot.bindTo(textWX);\ntWZRot.bindTo(textWZ);\ntZYRot.bindTo(textZY);\nboard.update();\n\nreturn div;"}}, "metadata": {"description": "

Draws a triangle based on 3 side lengths.

", "licence": "Creative Commons Attribution 4.0 International"}, "advice": "

Avoid using rounded values in calculations and just round for the final answer.

", "tags": [], "type": "question", "contributors": [{"name": "Mark Hodds", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/510/"}]}]}], "contributors": [{"name": "Mark Hodds", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/510/"}]}