WeBWorK Problems

degrees symbol (sup 0) in graph label

degrees symbol (sup 0) in graph label

by Hedley Pinsent -
Number of replies: 2
I want to put a "degrees symbol" superscript - 0 in a graph label.


vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$Given[2] = "=". $X[2].??; where the ?? needs to contain sup 0
...
$Alabel = "A".$Given[$n3k[0]];
...
$lab=new Label($AX,$AY,$Alabel,'black','bottom','left');
$pic->lb($lab);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The full example is below.

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
For those interested ...
It is an exercise about irregular triangles
The output is the contents of @case
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Thanks in advance.
hp


# rest of document is pg file #VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV

##DESCRIPTION
## DBsubject('')
## DBchapter('')
## DBsection('')
## KEYWORDS('', '')
## Author('')
## Institution('')
##ENDDESCRIPTION


DOCUMENT();

loadMacros(
"PG.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"PGauxiliaryFunctions.pl",
"PGgraphmacros.pl",
"PGasu.pl",
"unionTables.pl","unionMacros.pl"
);
#######################
TEXT(&beginproblem);

$showPartialCorrectAnswers = 1;
#########general - work in progress ######
# case 0 - sss
# case 1 - sas cosine law acute
# case 2 - sas cosine law obtuse
# case 3 - ass acute
# case 4 - ass obtuse
# case 5 - asa
###########################################
@list0 = (5,6,7,8,9,10);
@list0 = @list0 [NchooseK(6,6)];
@list1 = @list0 [NchooseK(6,6)];
@list2 = @list1 [NchooseK(6,6)];
@list3 = (50,60,70,80,90,100);
@list3 = @list3 [NchooseK(6,6)];
@list4 = @list3 [NchooseK(6,6)];
@list5 = @list4 [NchooseK(6,6)];


@Acutelist = (20,30,40,55,65,75);
@Acutelist = @Acutelist [NchooseK(6,6)];

@smallAcutelist = (10,15,20,25,30,35);
@smallAcutelist = @smallAcutelist [NchooseK(6,6)];
@smallAcutelist5 = @smallAcutelist [NchooseK(6,6)];

@Obtuselist = (110,130,140,155 );
@Obtuselist = @Obtuselist [NchooseK(4,4)];


$trial = 0;
$count0 = 0;
$count1 = 0;
$count2 = 0;
$count3 = 0;
$count4 = 0;
$count5 = 0;


@case = (0,1,2,3,4,5);
@case = @case [NchooseK(6,6)];

foreach my $case (@case) {
# do something for each frame
$trial = $trial + 1;


if ($case == 0){ ###sss
$x[0] = $list0[0+$icount0];
$x[1] = $list0[1+$icount0];
$x[2] = $list0[2+$icount0];
$icount0 = $icount0 + 1;
#use cosine law to find angles
$X[0] = (180/$PI)*acos (( $x[1]**2 + $x[2]**2- $x[0]**2)/(2*$x[1]*$x[2]));
$X[1] = (180/$PI)*acos (( $x[0]**2 + $x[2]**2- $x[1]**2)/(2*$x[0]*$x[2]));

$X[2] = 180 - $X[0] - $X[1] ;
$A = $X[0];
$B = $X[1];
$C = $X[2];
$a = $x[0];
$b = $x[1];
$c = $x[2];
$Alabel = "A";
$Blabel = "B";
$Clabel = "C";
$alabel = "a = $a";
$blabel = "b = $b";
$clabel = "c = $c";
}




if ($case == 1){ ###sas acute angle#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

$x[0] = $list1[0 + $icount1];
$x[1] = $list1[1 + $icount1];
$X[2] = $Acutelist[0 + $icount1];
$icount1 = $icount1 + 1;
$x[2] = sqrt ($x[0]**2 + $x[1]**2 - 2 * $x[0] * $x[1] * cos($PI / 180 * $X[2]));
#use cosine law to find angles
$X[0] = (180/$PI)*acos (( $x[1]**2 + $x[2]**2 - $x[0]**2)/(2*$x[1]*$x[2]));
$X[1] = (180/$PI)*acos (( $x[0]**2 + $x[2]**2 - $x[1]**2)/(2*$x[0]*$x[2]));


@n3k = NchooseK(3,3);


$A = $X[$n3k[0]];
$Given[0] = "";
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "=". $X[2];
$a = $x[$n3k[0]];
$given[0] = "= ". $x[0];
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = "A".$Given[$n3k[0]];
$Blabel = "B".$Given[$n3k[1]];
$Clabel = "C ".$Given[$n3k[2]];
$alabel = "a ".$given[$n3k[0]];
$blabel = "b ".$given[$n3k[1]];
$clabel = "c".$given[$n3k[2]];
} #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^




if ($case == 2){ ###sas obtuse ###vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$x[0] = $list2[0 + $icount2];
$x[1] = $list2[1+ $icount2];
$X[2] = $Obtuselist[0+ $icount2];
$icount2 = $icount2 + 1;
$x[2] = sqrt ($x[0]**2 + $x[1]**2 - 2 * $x[0] * $x[1] * cos($PI / 180 * $X[2]));
#use cosine law to find angles
$X[0] = (180/$PI)*acos (( $x[1]**2 + $x[2]**2- $x[0]**2)/(2*$x[1]*$x[2]));
$X[1] = (180/$PI)*acos (( $x[0]**2 + $x[2]**2- $x[1]**2)/(2*$x[0]*$x[2]));

@n3k = NchooseK(3,3);

$A = $X[$n3k[0]];
$Given[0] = "";
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "= ". $X[2];
$a = $x[$n3k[0]];
$given[0] = "= ". $x[0];
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = "A".$Given[$n3k[0]];
$Blabel = "B".$Given[$n3k[1]];
$Clabel = "C ".$Given[$n3k[2]];
$alabel = "a ".$given[$n3k[0]];
$blabel = "b ".$given[$n3k[1]];
$clabel = "c".$given[$n3k[2]];
} # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

if ($case == 3){ ###ass acute



$x[1] = $list3[0 + $icount3];
$X[0] = $smallAcutelist[0 + $icount3];
$icount3 = $icount3 + 1;


# for the other given side vvvvvvvvvvv
$minLength = int( 1.1 *$x[1]* sin ($PI / 180 * $X[0]) + 1);
$maxLength = int(0.7 * $x[1]);
$x[0] = random ($minLength, $maxLength);
#for the other given side ^^^^^^^^^^^^

$X[1] = 180 / $PI * asin(sin ($PI / 180 * $X[0]) / $x[0] * $x[1]);
$X[2] = 180 - $X[0] - $X[1];
$x[2] = sqrt($x[0]**2 + $x[1]**2 - 2 * $x[0]*$x[1] * cos($PI / 180 * $X[2]));


@n3k = NchooseK(3,3);

$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0];
$B = $X[$n3k[1]];
$Given[1] = "(acute)";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "= ". $x[0];
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = "A".$Given[$n3k[0]];
$Blabel = "B".$Given[$n3k[1]];
$Clabel = "C ".$Given[$n3k[2]];
$alabel = "a ".$given[$n3k[0]];
$blabel = "b ".$given[$n3k[1]];
$clabel = "c".$given[$n3k[2]];
}

if ($case == 4){ ###ass obtuse




$x[1] = $list4[0 + $icount4];
$X[0] = $smallAcutelist[0 + $icount4];
$icount4 = $icount4 + 1;
# for the other given side vvvvvvvvvvv
$minLength = int( 1.1 * $x[1]* sin ($PI / 180 * $X[0]) + 1);
$maxLength = int(0.7 * $x[1]);
$x[0] = random ($minLength, $maxLength);
#for the other given side ^^^^^^^^^^^^

$X[1] = 180 - (180 / $PI) * asin(sin (($PI / 180) * $X[0]) * $x[1] / $x[0]);

$X[2] = 180 - $X[0] - $X[1];
$x[2] = sqrt($x[0]**2 + $x[1]**2 - 2 * $x[0]*$x[1] * cos($PI * $X[2] / 180));



@n3k = NchooseK(3,3);

$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0];
$B = $X[$n3k[1]];
$Given[1] = "(obtuse)";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "= ". $x[0];
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = "A".$Given[$n3k[0]];
$Blabel = "B".$Given[$n3k[1]];
$Clabel = "C ".$Given[$n3k[2]];
$alabel = "a ".$given[$n3k[0]];
$blabel = "b ".$given[$n3k[1]];
$clabel = "c".$given[$n3k[2]];

}

if ($case == 5){ ###asa


# given vvvvvvvvvvvvvvv
$x[1] = $list5[0 + $icount5];
$X[0] = $smallAcutelist5[0 + $icount5];
$icount5 = $icount5 + 1;
$X[2] = random(30,160 - $X[0],5);
# given ^^^^^^^^^^^^^^^^^^^^^^


$X[1] = 180 - $X[0] - $X[2] ;
$x[2] = sin ($PI / 180 * $X[2]) * $x[1] / sin ($PI / 180 * $X[1]);
$x[0] = sin ($PI / 180 * $X[0]) * $x[1] / sin ($PI / 180 * $X[1]);




@n3k = NchooseK(3,3);

$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0];
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "=".$X[2];
$a = $x[$n3k[0]];
$given[0] = "";
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = "A".$Given[$n3k[0]];
$Blabel = "B".$Given[$n3k[1]];
$Clabel = "C ".$Given[$n3k[2]];
$alabel = "a ".$given[$n3k[0]];
$blabel = "b ".$given[$n3k[1]];
$clabel = "c".$given[$n3k[2]];
}





#$a = $list[0];
#$b = $a * sin ($PI * $B / 180) / sin ($PI * $A / 180);
$bdisp = round ($b * 100 ) / 100 ;
#$c = $a * sin ($PI * $C / 180) / sin ($PI * $A / 180);
$cdisp = round ($c * 100 ) / 100 ;

$AX = $b * cos ($PI * $C / 180);
$AY = $b * sin ($PI * $C / 180);


#$dimX = max ($a, $a - $AX);
$dimX = max (max ($a, $a - $AX), $AX);
$dimY = $AY ;
$size = 1.5 * max ($dimX, $dimY);
$marginX = 0.5 * ($size - $dimX);
$marginY = 0.5 * ($size - $AY);

$xmin = min(0,$AX ) - $marginX;
$xmax = $size + $xmin;
$ymin = -1 * $marginY;
$ymax = $size - $marginY;



$xPixels = 600;
$yPixels = 600;


$pic = init_graph($xmin,$ymin,$xmax,$ymax,'pixels'=>[$xPixels,$yPixels]);


$lab=new Label(0,0,$Clabel,'black','top','center');
$pic->lb($lab);

$lab=new Label($AX,$AY,$Alabel,'black','bottom','left');
$pic->lb($lab);

$lab=new Label($a,0,$Blabel);
$pic->lb($lab);

$lab=new Label($a/2,0,$alabel,'black','center','top');
$pic->lb($lab);

$lab=new Label($AX/2,$AY/2,$blabel,'black','right','middle');
$pic->lb($lab);

$lab=new Label(($AX + $a) / 2 , $AY /2 ,$clabel, 'black','left','bottom');
$pic->lb($lab);

$pic->new_color("lightblue", 214,230,244);
$pic->moveTo(0,0);
$pic->lineTo($AX,$AY,1);
$pic->lineTo($a,0,1);
$pic->lineTo(0,0,1);
$pic->fillRegion([($a / 2 + $AX)/2,$AY/2,'lightblue']);


##Constructing the data table vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$table = BeginTable(spacing => 3);


$table .= AlignedRow(["\( \angle A = \)",NAMED_ANS_RULE("angleA".$trial,6),"a =",NAMED_ANS_RULE("SIDEa".$trial,6)]);
push @namedCmp , "angleA".$trial=>num_cmp( $A, reltol=>3 ) ;
push @namedCmp , "SIDEa".$trial=>num_cmp( $a , reltol=>3 ) ;
$table .= AlignedRow(["\( \angle B = \)",NAMED_ANS_RULE("angleB".$trial,6),"b =",NAMED_ANS_RULE("SIDEb".$trial,6)]);

push @namedCmp , "angleB".$trial=>num_cmp( $B, reltol=>3 ) ;
push @namedCmp , "SIDEb".$trial=>num_cmp( $b , reltol=>3 ) ;

$table .= AlignedRow(["\( \angle C = \)",NAMED_ANS_RULE("angleC".$trial,6),"c =",NAMED_ANS_RULE("SIDEc".$trial,6)]);

push @namedCmp , "angleC".$trial=>num_cmp( $C, reltol=>3 ) ;
push @namedCmp , "SIDEc".$trial=>num_cmp( $c , reltol=>3 ) ;



$table .= EndTable();

##Constructing the data table ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

BEGIN_TEXT

$HR $HR Number $trial $BR

\{ image(insertGraph($pic), width=>$xPixels+200, height=>$yPixels+200) \}
$PAR
Complete the chart for the accompanying triangle.

$PAR
$table



END_TEXT

NAMED_ANS(@namedCmp);



}

ENDDOCUMENT();

In reply to Hedley Pinsent

Re: degrees symbol (sup 0) in graph label

by Hedley Pinsent -
Ha Ha
Just found it

$deg = "".sprintf("%c",0xb0);

$Given[0] = "= ". $X[0].$deg;
...
$Alabel = "A".$Given[$n3k[0]];
...
$lab=new Label($AX,$AY,$Alabel,'black','bottom','left');
$pic->lb($lab);

Will post complete working example shortly.

Thanks

hp
In reply to Hedley Pinsent

Re: degrees symbol (sup 0) in graph label

by Hedley Pinsent -
Here is the working example.
It is also a document on triangles.
Still needs filling in; never seems to end.
Thanks for listening

hp


######start of example (to end) ##########
##DESCRIPTION
## DBsubject('')
## DBchapter('')
## DBsection('')
## KEYWORDS('', '')
## Author('')
## Institution('')
##ENDDESCRIPTION


DOCUMENT();

loadMacros(
"PG.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"PGauxiliaryFunctions.pl",
"PGgraphmacros.pl",
"PGasu.pl",
"unionTables.pl","unionMacros.pl"
);
#######################
TEXT(&beginproblem);

$showPartialCorrectAnswers = 1;
#########general - work in progress ######
# case 0 - LL90 pythagoras
# case 0.5 - LL90 pythagoras - small angles
# case 1 - HL90 pythagoras
# case 1.5 - HL90 pythagoras - small angles
# case 2 - LL90 solve
# case 3 - HL90 solve
# case 4 - AL90 solve
# case 5 - AH90 solve
# case 6 - sss
# case 7 - sas cosine law acute
# case 7.5 - sas acute - find opposite side only
# case 8 - sas cosine law obtuse
# case 9 - ass acute
# case 10 - ass obtuse
# case 11 - asa
###########################################
@list0 = (5,6,7,8,9,10);
@list0 = @list0 [NchooseK(6,6)];
@list0p5 = @list0 [NchooseK(6,6)];
@list1 = @list0 [NchooseK(6,6)];
@list1p5 = @list0 [NchooseK(6,6)];
@list2 = @list1 [NchooseK(6,6)];
@list3 = @list2 [NchooseK(6,6)];
@list4 = @list3 [NchooseK(6,6)];
@list5 = @list4 [NchooseK(6,6)];
@list6 = @list5 [NchooseK(6,6)];
@list7 = @list6 [NchooseK(6,6)];
@list7p5 = @list6 [NchooseK(6,6)];
@list8 = @list7 [NchooseK(6,6)];
@list9 = (50,60,70,80,90,100);
@list9 = @list9 [NchooseK(6,6)];
@list10 = @list9 [NchooseK(6,6)];
@list11 = @list10 [NchooseK(6,6)];


@Acutelist = (20,30,40,55,65,75);
@Acutelist = @Acutelist [NchooseK(6,6)];

@smallAcutelist = (10,15,20,25,30,35);
@smallAcutelist = @smallAcutelist [NchooseK(6,6)];
@smallAcutelist11 = @smallAcutelist [NchooseK(6,6)];

@Acutelist4 = @Acutelist [NchooseK(6,6)];
@Acutelist5 = @Acutelist4 [NchooseK(6,6)];

@Obtuselist = (110,130,140,155 );
@Obtuselist = @Obtuselist [NchooseK(4,4)];


$trial = 0;
$count0p5 =0;
$count0 = 0;
$count1 = 0;
$count1p5 =0;
$count2 = 0;
$count3 = 0;
$count4 = 0;
$count5 = 0;
$count6 = 0;
$count7 = 0;
$count7p5 = 0;
$count8 = 0;
$count9 = 0;
$count10 = 0;
$count11 = 0;

$deg = "".sprintf("%c",0xb0);


@case = (0,1,2,3,4,5);
@case = @case [NchooseK(6,6)];
@case = (0,0.5,1,1.5,2,3,4,5,6,7,7.5,8,9,10,11);
@n3k = NchooseK(3,3);

foreach my $case (@case) {
# do something for each frame
$trial = $trial + 1;
$TABLEoverride = 0;


@n3k = @n3k[1,2,0];
if($trial/3 == int($trial/3)){@n3k = @n3k[0,2,1]}

# Sets of labels vvvvvvvvvvvvvvvvvvvv
@Angles = ("A","B","C","W","X","Y","X","Y","Z","I","J","K");
@Sides = ("a","b","c","w","x","y","x","y","z","i","j","k");
$tmpSTART = random(0,9,3);
$AL = @Angles[$tmpSTART + 0];
$LL[$n3k[0]] = $AL;
$BL = @Angles[$tmpSTART + 1];
$LL[$n3k[1]] = $BL;
$CL = @Angles[$tmpSTART + 2];
$LL[$n3k[2]] = $CL;
$aL = @Sides[$tmpSTART + 0];
$ll[$n3k[0]] = $aL;
$bL = @Sides[$tmpSTART + 1];
$ll[$n3k[1]] = $bL;
$cL = @Sides[$tmpSTART + 2];
$ll[$n3k[2]] = $cL;
# Sets of labels ^^^^^^^^^^^^^^^^^^^


if ($case == 0){ ###LL90 find hyptoneuse only

$x[1] = $list3[0 + $icount0];
$X[0] = 90;
$x[2] = $list3[1 + $icount0]; # the other leg
$icount0 = $icount0 + 1;



$x[0] = sqrt($x[1]**2 + $x[2]**2 ); #the hypotenuse
$X[1] = 180 / $PI * asin( $x[1] / $x[0] );
$X[2] = 180 - $X[0] - $X[1];


$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "";
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "= ". $x[2];
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];


$TABLEoverride = 1;

##Constructing the data table vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$table = BeginTable(spacing => 3);

$TABLEoverride = 1;
$table .= AlignedRow(["The length of side $ll[0] is ",NAMED_ANS_RULE("answer".$trial,6)]);


push @namedCmp , "answer".$trial=>num_cmp( $x[0], reltol=>3 ) ;




$table .= EndTable();
}
if ($case == 0.5){ ###LL90 find hyptoneuse only small numbers

$x[1] = $list0p5[0 + $icount0_5]/100;
$X[0] = 90;
$x[2] = $list0p5[1 + $icount0_5]/100; # the other leg
$icount0_5 = $icount0_5 + 1;



$x[0] = sqrt($x[1]**2 + $x[2]**2 ); #the hypotenuse
$X[1] = 180 / $PI * asin( $x[1] / $x[0] );
$X[2] = 180 - $X[0] - $X[1];


$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "";
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "= ". $x[2];
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];



##Constructing the data table vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$table = BeginTable(spacing => 3);

$TABLEoverride = 1;
$table .= AlignedRow(["The length of side $ll[0] is ",NAMED_ANS_RULE("answer".$trial,6)]);


push @namedCmp , "answer".$trial=>num_cmp( $x[0], reltol=>3 ) ;




$table .= EndTable();
}


if ($case == 1){ ###HL90 missing side only



$x[1] = $list1[0 + $icount1];
$X[0] = 90;
$icount1 = $icount1 + 1;
$x[0] = random(int(1.2 * $x[1] + 1),int(5 * $x[1])); # the hypotenuse



$X[1] = 180 / $PI * asin( $x[1] / $x[0] );
$X[2] = 180 - $X[0] - $X[1];
$x[2] = sqrt($x[0]**2 - $x[1]**2 );




$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "= ". $x[0];
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];



##Constructing the data table vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$table = BeginTable(spacing => 3);

$TABLEoverride = 1;
$table .= AlignedRow(["The length of side $ll[2] is ",NAMED_ANS_RULE("answer".$trial,6)]);


push @namedCmp , "answer".$trial=>num_cmp( $x[2], reltol=>3 ) ;




$table .= EndTable();
}



if ($case == 1.5){ ###HL90 missing side only



$x[1] = $list1p5[0 + $icount1p5];
$X[0] = 90;
$icount1 = $icount1p5 + 1;
$x[0] = random(int(1.2 * $x[1] + 1),int(5 * $x[1]))/1000; # the hypotenuse
$x[1] = $x[1]/1000;


$X[1] = 180 / $PI * asin( $x[1] / $x[0] );
$X[2] = 180 - $X[0] - $X[1];
$x[2] = sqrt($x[0]**2 - $x[1]**2 );




$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "= ". $x[0];
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];



##Constructing the data table vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$table = BeginTable(spacing => 3);

$TABLEoverride = 1;
$table .= AlignedRow(["The length of side $ll[2] is ",NAMED_ANS_RULE("answer".$trial,6)]);


push @namedCmp , "answer".$trial=>num_cmp( $x[2], reltol=>3 ) ;




$table .= EndTable();
}

if ($case == 2){ ###LL90 solve



$x[1] = $list2[0 + $icount2];
$X[0] = 90;
$x[2] = $list2[1 + $icount2]; # the other leg
$icount2 = $icount2 + 1;



$x[0] = sqrt($x[1]**2 + $x[2]**2 ); #the hypotenuse
$X[1] = 180 / $PI * asin( $x[1] / $x[0] );
$X[2] = 180 - $X[0] - $X[1];


$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "";
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "= ". $x[2];
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];
}






if ($case == 3){ ###HL90 solve



$x[1] = $list3[0 + $icount3];
$X[0] = 90;
$icount3 = $icount3 + 1;
$x[0] = random(int(1.2 * $x[1] + 1),int(5 * $x[1])); # the hypotenuse



$X[1] = 180 / $PI * asin( $x[1] / $x[0] );
$X[2] = 180 - $X[0] - $X[1];
$x[2] = sqrt($x[0]**2 - $x[1]**2 );




$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "= ". $x[0];
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";

$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];


}




if ($case == 4){ ###as90


# given vvvvvvvvvvvvvvv
$x[1] = $list4[0 + $icount4];
$X[0] = $Acutelist4[0 + $icount4];
$icount4 = $icount4 + 1;
$X[2] = 90;
# given ^^^^^^^^^^^^^^^^^^^^^^


$X[1] = 180 - $X[0] - $X[2] ;
$x[2] = $x[1] / sin ($PI / 180 * $X[1]);
$x[0] = sin ($PI / 180 * $X[0]) * $x[1] / sin ($PI / 180 * $X[1]);





$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "=".$X[2].$deg;
$a = $x[$n3k[0]];
$given[0] = "";
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];
}


if ($case == 5){ ###ah90


# given vvvvvvvvvvvvvvv
$x[1] = $list5[0 + $icount5];
$X[0] = $Acutelist5[0 + $icount5];
$icount5 = $icount5 + 1;
$X[1] = 90;
# given ^^^^^^^^^^^^^^^^^^^^^^


$X[2] = 180 - $X[0] - $X[1] ;
$x[2] = sin ($PI / 180 * $X[2]) * $x[1] ;
$x[0] = sin ($PI / 180 * $X[0]) * $x[1] ;






$A = $X[$n3k[0]];
$Given[0] = " = ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = " = ".$X[1].$deg;
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "";
$b = $x[$n3k[1]];
$given[1] = " = ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];
}



if ($case == 6){ ###sss
$x[0] = $list6[0+$icount6];
$x[1] = $list6[1+$icount6];
$x[2] = $list6[2+$icount6];
$icount6 = $icount6 + 1;
#use cosine law to find angles
$X[0] = (180/$PI)*acos (( $x[1]**2 + $x[2]**2- $x[0]**2)/(2*$x[1]*$x[2]));
$X[1] = (180/$PI)*acos (( $x[0]**2 + $x[2]**2- $x[1]**2)/(2*$x[0]*$x[2]));

$X[2] = 180 - $X[0] - $X[1] ;
$A = $X[0];
$B = $X[1];
$C = $X[2];
$a = $x[0];
$b = $x[1];
$c = $x[2];
$Alabel = $AL;
$Blabel = $BL;
$Clabel = $CL;
$alabel = "$aL = $a";
$blabel = "$bL = $b";
$clabel = "$cL = $c";
}




if ($case == 7){ ###sas acute angle#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

$x[0] = $list7[0 + $icount7];
$x[1] = $list7[1 + $icount7];
$X[2] = $Acutelist[0 + $icount7];
$icount7 = $icount7 + 1;
$x[2] = sqrt ($x[0]**2 + $x[1]**2 - 2 * $x[0] * $x[1] * cos($PI / 180 * $X[2]));
#use cosine law to find angles
$X[0] = (180/$PI)*acos (( $x[1]**2 + $x[2]**2 - $x[0]**2)/(2*$x[1]*$x[2]));
$X[1] = (180/$PI)*acos (( $x[0]**2 + $x[2]**2 - $x[1]**2)/(2*$x[0]*$x[2]));





$A = $X[$n3k[0]];
$Given[0] = "";
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "=". $X[2].$deg;
$a = $x[$n3k[0]];
$given[0] = "= ". $x[0];
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];
} #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

if ($case == 7.5){ ###sas acute angle#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

$x[0] = $list7p5[0 + $icount7p5];
$x[1] = $list7p5[1 + $icount7p5];
$X[2] = $Acutelist[0 + $icount7p5];
$icount7p5 = $icount7p5 + 1;
$x[2] = sqrt ($x[0]**2 + $x[1]**2 - 2 * $x[0] * $x[1] * cos($PI / 180 * $X[2]));
#use cosine law to find angles
$X[0] = (180/$PI)*acos (( $x[1]**2 + $x[2]**2 - $x[0]**2)/(2*$x[1]*$x[2]));
$X[1] = (180/$PI)*acos (( $x[0]**2 + $x[2]**2 - $x[1]**2)/(2*$x[0]*$x[2]));





$A = $X[$n3k[0]];
$Given[0] = "";
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "=". $X[2].$deg;
$a = $x[$n3k[0]];
$given[0] = "= ". $x[0];
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];

$TABLEoverride = 1;

##Constructing the data table vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$table = BeginTable(spacing => 3);
$table .= AlignedRow(["The length of side $ll[2] is ",NAMED_ANS_RULE("answer".$trial,6)]);


push @namedCmp , "answer".$trial=>num_cmp( $x[0], reltol=>3 ) ;




$table .= EndTable();

} #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^






if ($case == 8){ ###sas obtuse ###vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$x[0] = $list8[0 + $icount8];
$x[1] = $list8[1+ $icount8];
$X[2] = $Obtuselist[0+ $icount8];
$icount8 = $icount8 + 1;
$x[2] = sqrt ($x[0]**2 + $x[1]**2 - 2 * $x[0] * $x[1] * cos($PI / 180 * $X[2]));
#use cosine law to find angles
$X[0] = (180/$PI)*acos (( $x[1]**2 + $x[2]**2- $x[0]**2)/(2*$x[1]*$x[2]));
$X[1] = (180/$PI)*acos (( $x[0]**2 + $x[2]**2- $x[1]**2)/(2*$x[0]*$x[2]));



$A = $X[$n3k[0]];
$Given[0] = "";
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "= ". $X[2].$deg;
$a = $x[$n3k[0]];
$given[0] = "= ". $x[0];
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];
} # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

if ($case == 9){ ###ass acute



$x[1] = $list9[0 + $icount9];
$X[0] = $smallAcutelist[0 + $icount9];
$icount9 = $icount9 + 1;


# for the other given side vvvvvvvvvvv
$minLength = int( 1.1 *$x[1]* sin ($PI / 180 * $X[0]) + 1);
$maxLength = int(0.7 * $x[1]);
$x[0] = random ($minLength, $maxLength);
#for the other given side ^^^^^^^^^^^^

$X[1] = 180 / $PI * asin(sin ($PI / 180 * $X[0]) / $x[0] * $x[1]);
$X[2] = 180 - $X[0] - $X[1];
$x[2] = sqrt($x[0]**2 + $x[1]**2 - 2 * $x[0]*$x[1] * cos($PI / 180 * $X[2]));




$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "(acute)";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "= ". $x[0];
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];
}

if ($case == 10){ ###ass obtuse




$x[1] = $list10[0 + $icount10];
$X[0] = $smallAcutelist[0 + $icount10];
$icount10 = $icount10 + 1;
# for the other given side vvvvvvvvvvv
$minLength = int( 1.1 * $x[1]* sin ($PI / 180 * $X[0]) + 1);
$maxLength = int(0.7 * $x[1]);
$x[0] = random ($minLength, $maxLength);
#for the other given side ^^^^^^^^^^^^

$X[1] = 180 - (180 / $PI) * asin(sin (($PI / 180) * $X[0]) * $x[1] / $x[0]);

$X[2] = 180 - $X[0] - $X[1];
$x[2] = sqrt($x[0]**2 + $x[1]**2 - 2 * $x[0]*$x[1] * cos($PI * $X[2] / 180));



@n3k = NchooseK(3,3);

$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "(obtuse)";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "= ". $x[0];
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];

}

if ($case == 11){ ###asa


# given vvvvvvvvvvvvvvv
$x[1] = $list11[0 + $icount11];
$X[0] = $smallAcutelist11[0 + $icount11];
$icount11 = $icount11 + 1;
$X[2] = random(30,160 - $X[0],5);
# given ^^^^^^^^^^^^^^^^^^^^^^


$X[1] = 180 - $X[0] - $X[2] ;
$x[2] = sin ($PI / 180 * $X[2]) * $x[1] / sin ($PI / 180 * $X[1]);
$x[0] = sin ($PI / 180 * $X[0]) * $x[1] / sin ($PI / 180 * $X[1]);






$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "=".$X[2].$deg;
$a = $x[$n3k[0]];
$given[0] = "";
$b = $x[$n3k[1]];
$given[1] = "= ". $x[1];
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];
}




$bdisp = round ($b * 100 ) / 100 ;

$cdisp = round ($c * 100 ) / 100 ;

$AX = $b * cos ($PI * $C / 180);
$AY = $b * sin ($PI * $C / 180);


$dimX = max (max ($a, $a - $AX), $AX);
$dimY = $AY ;
$size = 1.5 * max ($dimX, $dimY);
$marginX = 0.5 * ($size - $dimX);
$marginY = 0.5 * ($size - $AY);

$xmin = min(0,$AX ) - $marginX;
$xmax = $size + $xmin;
$ymin = -1 * $marginY;
$ymax = $size - $marginY;



$xPixels = 600;
$yPixels = 600;


$pic = init_graph($xmin,$ymin,$xmax,$ymax,'pixels'=>[$xPixels,$yPixels]);


$lab=new Label(0,0,$Clabel,'black','top','center');
$pic->lb($lab);

$lab=new Label($AX,$AY,$Alabel,'black','bottom','left');
$pic->lb($lab);

$lab=new Label($a,0,$Blabel);
$pic->lb($lab);

$lab=new Label($a/2,0,$alabel,'black','center','top');
$pic->lb($lab);

$lab=new Label($AX/2- abs(0.03 *$a),$AY/2,$blabel,'black','right','bottom');
$pic->lb($lab);

$lab=new Label(($AX + $a) / 2 + abs(0.03 *$a), $AY /2 ,$clabel, 'black','left','bottom');
$pic->lb($lab);

$pic->new_color("lightblue", 214,230,244);
$pic->moveTo(0,0);
$pic->lineTo($AX,$AY,1);
$pic->lineTo($a,0,1);
$pic->lineTo(0,0,1);
$pic->fillRegion([($a / 2 + $AX)/2,$AY/2,'lightblue']);

if ($TABLEoverride == 0){
##Constructing the data table vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$table = BeginTable(spacing => 3);


$table .= AlignedRow(["\( \angle $AL = \)",NAMED_ANS_RULE("angleA".$trial,6),"$aL =",NAMED_ANS_RULE("SIDEa".$trial,6)]);
push @namedCmp , "angleA".$trial=>num_cmp( $A, reltol=>3 ) ;
push @namedCmp , "SIDEa".$trial=>num_cmp( $a , reltol=>3 ) ;
$table .= AlignedRow(["\( \angle $BL = \)",NAMED_ANS_RULE("angleB".$trial,6),"$bL =",NAMED_ANS_RULE("SIDEb".$trial,6)]);

push @namedCmp , "angleB".$trial=>num_cmp( $B, reltol=>3 ) ;
push @namedCmp , "SIDEb".$trial=>num_cmp( $b , reltol=>3 ) ;

$table .= AlignedRow(["\( \angle $CL = \)",NAMED_ANS_RULE("angleC".$trial,6),"$cL =",NAMED_ANS_RULE("SIDEc".$trial,6)]);

push @namedCmp , "angleC".$trial=>num_cmp( $C, reltol=>3 ) ;
push @namedCmp , "SIDEc".$trial=>num_cmp( $c , reltol=>3 ) ;



$table .= EndTable();

##Constructing the data table ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}
BEGIN_TEXT

$HR $HR Number $trial $BR

\{ image(insertGraph($pic), width=>$xPixels+200, height=>$yPixels+200) \}
$PAR
Complete the chart for the accompanying triangle.

$PAR
$table


END_TEXT

NAMED_ANS(@namedCmp);



}

ENDDOCUMENT();