<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>17.2.1.2 Polar to Cartesian coordinates</text>
    </name>
    <questiontext format="moodle_auto_format">
      <text><![CDATA[<p>Two points \(P,Q\) have polar coordinates \([{@aa@},{@cc@}]\) and \([{@bb@},{@dd@}]\) respectively. By locating these points on a Cartesian plane find their equivalent Cartesian coordinates.</p>

<p>\(P(x, y) = (\)[[input:ans1]]\(,\) [[input:ans2]]\()\) [[validation:ans1]] [[validation:ans2]]</p>[[feedback:prt1]]

<p>\(Q(x, y) = (\)[[input:ans3]]\(,\) [[input:ans4]]\()\) [[validation:ans3]] [[validation:ans4]]</p>[[feedback:prt2]]]]></text>
    </questiontext>
    <generalfeedback format="moodle_auto_format">
      <text><![CDATA[<p>From the key point, we know that \(x = r\cos\theta\) and \(y= r\sin\theta\). Substituting in the values from the question, we get that the polar coordinates \([{@aa@},{@cc@}]\) correspond to the Cartesian coordinates \(({@aa@}\cos{@cc@}, {@aa@}\sin{@cc@}) = ({@taPx@}, {@taPy@})\), and the polar coordinates \([{@bb@},{@dd@}]\) correspond to the Cartesian coordinates \(({@bb@}\cos{@dd@}, {@bb@}\sin{@dd@})= ({@taQx@}, {@taQy@})\). See the graph below for a visual representation of this:</p>

[[jsxgraph]]
		
		var P_coord = [{#feedbackPx#}, {#feedbackPy#}]
		var Q_coord = [{#feedbackQx#}, {#feedbackQy#}]
		var Max_lengthx = Math.max(Math.abs(P_coord[0]), Math.abs(Q_coord[0]))
                var Max_lengthy = Math.max(Math.abs(P_coord[1]), Math.abs(Q_coord[1]))
        var board = JXG.JSXGraph.initBoard(divid, { 
            boundingbox: [-Max_lengthx-2, Max_lengthy+2, Max_lengthx+2, -Max_lengthy-2],
            keepaspectratio: true,
            showCopyright: false,
            axis: true,
            showNavigation: true,
        });
		
		JXG.Options.text.useMathJax = true;
		
		var P = board.create('point',P_coord, {name:'P',size:3, fixed:true});
		var Q = board.create('point',Q_coord, {name:'Q',size:3, fixed:true});
		
		var l1 = board.create('line', [P, [0, 0]], {straightFirst:false, straightLast:false ,firstArrow:true, name: '\\({#aa#}\\)', id: 'mag1', withLabel: true, color:'red', label:{anchorX: 'middle', anchorY: 'middle', position: '0.5fr left', distance: 1.2, offset:[20, 20], color: 'red'}});
		var l2 = board.create('line', [Q, [0, 0]], {straightFirst:false, straightLast:false ,firstArrow:true, name: '\\({#bb#}\\)', id: 'mag2', withLabel: true, color:'blue', label:{anchorX: 'middle', anchorY: 'middle',position: '0.5fr left', distance: 1.2, color:'blue', offset:[20, 20]}});
		
		var a = board.create('angle', [[1,0], [0, 0], P_coord ], {
			radius: 1.5, color:'red', withLabel: false, fixed: true
			});
		var t1_loc_x = 2.5*Math.cos(JXG.Math.Geometry.rad([1,0], [0, 0], P_coord)/2) [[comment]]places the text at the mid point of the angle, and out by 1 unit[[/comment]]
		var t1_loc_y = 2.5*Math.sin(JXG.Math.Geometry.rad([1,0], [0, 0], P_coord)/2)
		var t1 = board.create('text', [t1_loc_x, t1_loc_y, '\\(\\frac{{@feedbackdispangleP@}\\pi}{6}\\)'], {color:'red'});
		
		var b = board.create('angle', [[1,0], [0, 0], Q_coord ], {
			radius: 1, color:'blue', withLabel: false, fixed: true
			});
		var t2_loc_x = 2*Math.cos(JXG.Math.Geometry.rad([1,0], [0, 0], Q_coord)/2)
		var t2_loc_y = 2*Math.sin(JXG.Math.Geometry.rad([1,0], [0, 0], Q_coord)/2)
		var t2 = board.create('text', [t2_loc_x, t2_loc_y, '\\(\\frac{{@feedbackdispangleQ@}\\pi}{6}\\)'], {color:'blue'});

[[/jsxgraph]]]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2025040100</text>
    </stackversion>
    <questionvariables>
      <text><![CDATA[aa:rand(6)+2;
bb:rand_with_prohib(2, 8, [aa]);
cc:(rand(10)+1)*pi/6;
dd:rand_with_prohib(1,11, [bb*6])*pi/6

taPx:cos(cc)*aa;
taPy:sin(cc)*aa;
taQx:cos(dd)*bb;
taQy:sin(dd)*bb;

feedbackPx:float(cos(bb)*aa);
feedbackPy:float(sin(bb)*aa);
feedbackQx:float(cos(dd)*cc);
feedbackQy:float(sin(dd)*cc);

if (equal(cc*6/pi, 1)) then (feedbackdispangleP:"‎ ") else (feedbackdispangleP:cc*6/pi);
if (equal(dd*6/pi, 1)) then (feedbackdispangleQ:"‎ ") else (feedbackdispangleQ:dd*6/pi);]]></text>
    </questionvariables>
    <specificfeedback format="html">
      <text/>
    </specificfeedback>
    <questionnote format="html">
      <text>Polar coordinates \([{@aa@},{@cc@}]\) and \([{@bb@},{@dd@}]\) 
Cartesian coordinates \( [{@taPx@}, {@taPy@}] \) and \( [{@taQx@}, {@taQy@}] \)</text>
    </questionnote>
    <questiondescription format="html">
      <text/>
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <prtcorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:green;"><i class="fa fa-check"></i></span> Correct answer, well done.]]></text>
    </prtcorrect>
    <prtpartiallycorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:orange;"><i class="fa fa-adjust"></i></span> Your answer is partially correct.]]></text>
    </prtpartiallycorrect>
    <prtincorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:red;"><i class="fa fa-times"></i></span> Incorrect answer.]]></text>
    </prtincorrect>
    <decimals>.</decimals>
    <scientificnotation>*10</scientificnotation>
    <multiplicationsign>dot</multiplicationsign>
    <sqrtsign>1</sqrtsign>
    <complexno>i</complexno>
    <inversetrig>cos-1</inversetrig>
    <logicsymbol>lang</logicsymbol>
    <matrixparens>[</matrixparens>
    <isbroken>0</isbroken>
    <variantsselectionseed/>
    <input>
      <name>ans1</name>
      <type>algebraic</type>
      <tans>taPx</tans>
      <boxsize>7</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>ans2</name>
      <type>algebraic</type>
      <tans>taPy</tans>
      <boxsize>7</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>ans3</name>
      <type>algebraic</type>
      <tans>taQx</tans>
      <boxsize>7</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>ans4</name>
      <type>algebraic</type>
      <tans>taQy</tans>
      <boxsize>7</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <prt>
      <name>prt1</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans1</sans>
        <tans>taPx</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>0</truescore>
        <truepenalty/>
        <truenextnode>1</truenextnode>
        <trueanswernote>prt1-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
      <node>
        <name>1</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans2</sans>
        <tans>taPy</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-2-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>-</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-2-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>prt2</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans3</sans>
        <tans>taQx</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>+</truescoremode>
        <truescore>0</truescore>
        <truepenalty/>
        <truenextnode>1</truenextnode>
        <trueanswernote>prt2-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt2-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
      <node>
        <name>1</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans4</sans>
        <tans>taQy</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt2-2-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>-</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt2-2-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>965723328</deployedseed>
    <deployedseed>1969315666</deployedseed>
    <deployedseed>1547595025</deployedseed>
    <deployedseed>425537112</deployedseed>
    <deployedseed>1876311262</deployedseed>
    <deployedseed>1529490193</deployedseed>
    <deployedseed>1202988518</deployedseed>
    <deployedseed>1554704275</deployedseed>
    <deployedseed>686853424</deployedseed>
    <deployedseed>853868831</deployedseed>
    <deployedseed>757999333</deployedseed>
    <deployedseed>1057644337</deployedseed>
    <deployedseed>166250100</deployedseed>
    <deployedseed>1532099357</deployedseed>
    <deployedseed>766446974</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description>Test case assuming the teacher's input gets full marks.</description>
      <testinput>
        <name>ans1</name>
        <value>taPx</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>taPy</value>
      </testinput>
      <testinput>
        <name>ans3</name>
        <value>taQx</value>
      </testinput>
      <testinput>
        <name>ans4</name>
        <value>taQy</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt1-2-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt2-2-T</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
