## DESCRIPTION ## Statistics ## ENDDESCRIPTION ## KEYWORDS('Promotional Materials') ## Tagged by ## DBsubject('Logos') ## DBchapter('kite') ## DBsection('') ## Date('') ## Author('Hedley Pinsent') ## Institution('CNA') ## TitleText1('') ## EditionText1('') ## AuthorText1('') ## Section1('') ## Problem1('') # # First comes some stuff that appears at the beginning of every problem # DOCUMENT(); # This should be the first executable line in the problem. loadMacros( "PG.pl", "MathObjects.pl", "PGbasicmacros.pl", "PGchoicemacros.pl", "PGanswermacros.pl", "PGauxiliaryFunctions.pl", "PGasu.pl", "unionMacros.pl", "unionTables.pl", "PGgraphmacros.pl", "PGstatisticsmacros.pl","PGnumericalmacros.pl" ); TEXT($BEGIN_ONE_COLUMN,beginproblem()) ; # beginning of kite VVVVVVVVVVVV $refreshCachedImages = 1; #defining 3d parameters VVVVVVVVVVVVVV #body coordinates - focus (point at which eye is directed) $xf = -0.1; $yf = 0; #kite is in xy plane around 0,0 - approx 2 ft wide $zf = -0.2; #observer position in body coordinates $xo = -2; $yo = -2 ; $zo =-2 ; #15 feet below the kite #nose-spin --- observer spin counter-clockwise in degrees $Ntheta = -30; #paper distance and edge $paper_distance = .6; #1 foot from eye $paper_edge =0.4; # paper is a 1 ft square $dpi = 600; $base_line_width =int ( $dpi *12*$paper_edge/1000) ;#some adaptation to print parameters #here you would override the "viewing the paper center default"VVV $xmin = -1*$paper_edge /2 ; $ymin = -1*$paper_edge /2 +0.15; $xmax = $paper_edge /2 ; $ymax = $paper_edge/2 +0.15; #here you would override the "viewing the paper center default"^^^ $ymin = -1*$paper_edge /2 ; $ymax = $paper_edge/2 ; #we use translation and two rotations (complex numbers idea) #rotation about z axis so that y sort of point at kitevvvv #trig angles for rotation about z $hyp = sqrt(($xo-$xf)**2 +($yo-$yf)**2); if ($hyp < 0.1){ #observer close to the origin $cosThetaAboutZ = 1; $sinThetaAboutZ = 0; #no alteration } else { $cosThetaAboutZ = ($yf-$yo)/$hyp; $sinThetaAboutZ = ($xf-$xo)/$hyp;} #trig angles for rotation about x $y_post = $hyp; #post-revolutionary y $hyp = sqrt(($zf-$zo)**2 +($y_post)**2); if ($hyp < 0.1){ $cosThetaAboutX = 1; $sinThetaAboutX = 0; #no alteration } else { $sinThetaAboutX = ($y_post)/$hyp; $cosThetaAboutX = ($zf-$zo)/$hyp; } $cosThetaAboutZ2 = cos ($Ntheta *$PI /180); $sinThetaAboutZ2 = sin ($Ntheta *$PI /180); #defining 3d parameters ^^^^^^^^^^^^^^^ ### matrix cordinates wwwwwwwwwwwwwwwww $x1 = 0; $M11= $cosThetaAboutZ2 * $cosThetaAboutZ-1*$sinThetaAboutZ2*$cosThetaAboutX*$sinThetaAboutZ ; $M12= -1*$sinThetaAboutZ*$cosThetaAboutZ2 -1*$sinThetaAboutZ2*$cosThetaAboutX*$cosThetaAboutZ ; $M13= $sinThetaAboutZ2*$sinThetaAboutX ; $M21= $sinThetaAboutZ2* $cosThetaAboutZ+$cosThetaAboutZ2* $cosThetaAboutX*$sinThetaAboutZ ; $M22= -1*$sinThetaAboutZ*$sinThetaAboutZ2+$cosThetaAboutZ2 *$cosThetaAboutX*$cosThetaAboutZ ; $M23= -1 * $sinThetaAboutX*$cosThetaAboutZ2 ; $M31= $sinThetaAboutX*$sinThetaAboutZ ; $M32= $sinThetaAboutX*$cosThetaAboutZ ; $M33= $cosThetaAboutX ; ### matrix cordinates ^^^^^^^^^^^^^^^^^^^^^^^^^^ #defining the five corners (equidistant around a circle of radius 1) # this give a kite about 2 feet wide @x5 = ((1+$Xcenter),(cos(1.26)+$Xcenter),(cos(2.51)+$Xcenter),(cos(3.77)+$Xcenter),(cos(5.02)+$Xcenter),(1+$Xcenter)); @y5 = (0,sin(1.26),sin(2.51),sin(3.77),sin(5.02),0); @z5 = (0,0,0,0,0,0); # kite ^^^^^^^^^^^^^^^^^ ## setting up the graph vvvvvvvvvvvvvvvvvvvvvvvvvvv $gr = init_graph($xmin, $ymin, $xmax,$ymax, #axes=>[ 0, 0],grid => [4,4], size=>[12*$dpi*($xmax-$xmin),12*$dpi*($ymax-$ymin)]); # or pixes=>[400,400] $gr->lb('reset'); $gr->new_color("wwblue", 0,0,255); $gr->new_color("wwyellow", 255,255,204); #$gr->new_color("wwyellow", 255,255,196); #modified color #$gr->new_color("burg", 165,42,42); $Xcenter = -0.25; #Creating the frame VVVVVVVVVVVVVVVV foreach $tip (0..4){ $color = 'black'; $width = -10*$base_line_width; &PP($x5[$tip],$y5[$tip],0,1); foreach (1..100){ $x = $x5[$tip] + $_ * ($Xcenter - $x5[$tip] )/100; $y = $y5[$tip] - $_* ( $y5[$tip] )/100; &PP($x,$y,0,2); } } #Creating the frame ^^^^^^^^^^^^^^^^^^^^^^ #Joining the tips VVVVVVVVVVVVVVVVVVVV foreach $tip (0..4){ ; &PP($x5[$tip],$y5[$tip],0,1); foreach (0..100){ $x = $x5[$tip]+ $_*0.01 *($x5[$tip+1] - $x5[$tip]); $y = $y5[$tip]+ $_*0.01 *($y5[$tip+1] - $y5[$tip]); $BowFactor =0.3* (($x5[$tip]-$x)*($x-$x5[$tip+1])+($y5[$tip]-$y)*($y-$y5[$tip+1])); $x = $x - $BowFactor * ($y5[$tip+1]-$y5[$tip]); # bowing the edges $y = $y -$BowFactor * ($x5[$tip]-$x5[$tip+1]); # bowing the edges &PP($x,$y,0,2); } } #Joining the tips ^^^^^^^^^^^^^^^^^^^^^^^^ # doing the inner frame VVVVVVVVVVVV @xi5 = ((1+$Xcenter)/2,(cos(1.26)+$Xcenter)/2,(cos(2.51)+$Xcenter)/2,(cos(3.77)+$Xcenter)/2,(cos(5.02)+$Xcenter)/2,(1+$Xcenter)/2); @yi5 = (0,sin(1.26)/2,sin(2.51)/2,sin(3.77)/2,sin(5.02)/2,0); @zi5 = (0,0,0,0,0,0); foreach $tip (0..4){ ; &PP($xi5[$tip],$yi5[$tip],0,1); foreach (0..100){ $x = $xi5[$tip]+ $_*0.01 *($xi5[$tip+1] - $xi5[$tip]); $y = $yi5[$tip]+ $_*0.01 *($yi5[$tip+1] - $yi5[$tip]); $BowFactor =2* (($xi5[$tip]-$x)*($x-$xi5[$tip+1])+($yi5[$tip]-$y)*($y-$yi5[$tip+1])); $x = $x - $BowFactor * ($yi5[$tip+1]-$yi5[$tip]); # bowing the edges $y = $y -$BowFactor * ($xi5[$tip]-$xi5[$tip+1]); # bowing the edges &PP($x,$y,0,2); } } #Constructing the tail VVVVVVVVVVVV $width = -15*$base_line_width; &PP($x5[0],$y5[0],0,1); foreach (0..100){ $x = $x5[0]+ $_*0.01 *(2.5 - $x5[0]); $y = 0.2*( sin(6/(1+$x- $x5[0]) - 7.57)+1); $color = 'wwyellow'; PP($x, $y,0,2); } #objects on tail vvvvvvvvvvvvvvvvvv $width = -15*$base_line_width; foreach (10,30,50,70,90){ $color = 'wwyellow'; $x = $x5[0]+ $_*0.01 *(2.5 - $x5[0]); $y = 0.2*( sin(6/(1+$x- $x5[0]) - 7.57)+1); $delta_x = $x5[0]+ ($_+1)*0.01 *(2 - $x5[0]) - $x; $delta_y = 0.2*( sin(6/(1+$x+$delta_x- $x5[0]) - 7.57)+1)-$y; $dh = sqrt($delta_x**2 +$delta_y**2); $dx =0.05* $delta_x / $dh; $dy =0.05* $delta_y / $dh; &PP($x - $dy, $y + $dx,0,1); &PP($x + $dy, $y - $dx,0,2); } #objects on tail ^^^^^^^^^^^^^^^^ #Constructing the tail ^^^^^^^^^^^^^^^^ # doing the inner frame ^^^^^^^^^^^^^^^^^ #Coloring the regions VVVVVVVVVVVVVV $color = "wwblue"; &PP(0.7,0.7,0,3); #&PP(-0.8,0.8,0,3); #&PP(-0.8,-0.8,0,3); #&PP(8,-0.8,0,3); $color = "wwyellow"; foreach (0..4){ $xmid = ($x5[$_] + $xi5[$_+1])/2 ; $ymid = ($y5[$_] + $yi5[$_+1])/2 ; &PP($xmid ,$ymid,0,3); $xmid1 = ($Xcenter+$xi5[$_] )/2; $ymid1 = $yi5[$_] /2; $xmid2 = ($Xcenter+$xi5[$_+1] )/2; $ymid2 = $yi5[$_+1] /2; $xmid = ($xmid1+$xmid2)/2; $ymid = ($ymid1+$ymid2)/2; &PP($xmid ,$ymid,0,3); } #Coloring the regions ^^^^^^^^^^^^^^^^^^^ ## Setting up the graph ^^^^^^^^^^^^^^^^^^^^^^^^^ #Printing WeBWorK VVVVVVVVVVVVVVVV $gr ->moveTo($xmin, ($ymax-$ymin)/5+$ymin); $gr ->lineTo($xmax, ($ymax-$ymin)/5+$ymin,'wwyellow',1); @Wh = (1,1,3,3,5,5,7,7,9,9,11,11,10,1,2,11); @Wv = (2,11,11,3,3,11,11,3,3,11,11,3,2,2,3,1); @Wflag = (1,2,2,2,2,2,2,2,2,2,2,2,2,2,3,4); for ($index=0; $index < $#Wh+1; $index++){push (@XXh ,$Wh[$index])} for ($index=0; $index< $#Wv+1; $index++){push (@YYv ,$Wv[$index])} for ($index=0; $index< $#Wv+1; $index++){push (@XYflag ,$Wflag[$index])} for ($index=0; $index < $#Wh+1; $index++){push (@XXh ,$Wh[$index]+25)} for ($index=0; $index< $#Wv+1; $index++){push (@YYv ,$Wv[$index])} for ($index=0; $index< $#Wv+1; $index++){push (@XYflag ,$Wflag[$index])} @Bh = (1,1,5.6,7,7,6,6,7,7,6,1,3,3,5,5,3,3,3,5,5,3,2,4,4); @Bv = (2,11,11,10,7,7,6,6,3,2,2,3,6,6,3,3,7,10,10,7,7,3,4,8); @Bflag = (1,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,3,4,4); for ($index=0; $index < $#Bh+1; $index++){push (@XXh ,abs($Bh[$index])+18)} for ($index=0; $index< $#Bv+1; $index++){push (@YYv ,$Bv[$index])} for ($index=0; $index< $#Bv+1; $index++){push (@XYflag ,$Bflag[$index])} @eh = (1,1,2,6,7,7,3,3,5,5,7,7,6,2,1,3,3,5,5,3,2,4); @ev = (-3,8,9,9,8,5,5,3,3,4,4,3,2,2,3,-6,8,8,6,6,3,7); @eflag = (1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,3,4); for ($index=0; $index< $#eh+1; $index++){push (@XXh ,abs($eh[$index])+11)} for ($index=0; $index< $#ev+1; $index++){push (@YYv ,$ev[$index])} for ($index=0; $index< $#ev+1; $index++){push (@XYflag ,$eflag[$index])} @oh = (1,1,2,6,7,7,6,2,1,3,3,5,5,3,2,4); @ov = (-3,8,9,9,8,3,2,2,3,-3,8,8,3,3,3,7); @oflag = (1,2,2,2,2,2,2,2,2,1,2,2,2,2,3,4); for ($index=0; $index< $#oh+1; $index++){push (@XXh ,abs($oh[$index])+36)} for ($index=0; $index< $#ov+1; $index++){push (@YYv ,$ov[$index])} for ($index=0; $index< $#ov+1; $index++){push (@XYflag ,$oflag[$index])} @rh = (1,1,3,3,4,5,6,6,3,3,1,2); @rv = (-2,9,9,8,9,9,8,7,7,2,2,3); @rflag = (1,2,2,2,2,2,2,2,2,2,2,3); for ($index=0; $index< $#rh+1; $index++){push (@XXh ,abs($rh[$index])+43)} for ($index=0; $index< $#rv+1; $index++){push (@YYv ,$rv[$index])} for ($index=0; $index< $#rv+1; $index++){push (@XYflag ,$rflag[$index])} @Kh = (1,1,3,3,6,8,4,8,6,3,3,1,2); @Kv = (-2,11,11,7,11,11,6,2,2,5,2,2,3); @Kflag = (1,2,2,2,2,2,2,2,2,2,2,2,3); for ($index=0; $index < $#Kh+1; $index++){push (@XXh ,abs($Kh[$index])+49)} for ($index=0; $index< $#Kv+1; $index++){push (@YYv ,$Kv[$index])} for ($index=0; $index< $#Kv+1; $index++){push (@XYflag ,$Kflag[$index])} $xstart= -0.5*58/60 *($xmax -$xmin); for (0..$#XXh){ $x = (abs($XXh[$_]))*($xmax - $xmin)/60 + $xstart; $y = (abs($YYv[$_]))*($ymax - $ymin)/60 + $ymin; if ($XYflag[$_]==1){$gr->moveTo($x,$y)} if ($XYflag[$_]==2){$gr->lineTo($x,$y,'black',3)} if ($XYflag[$_]==3){$gr->fillRegion([$x,$y,'black'])} if ($XYflag[$_]==4){$gr->fillRegion([$x,$y,'wwyellow'])} } #Printing WeBWorK ^^^^^^^^^^^^^^^^^^^^^ #border around kite vvvvvvvvvv $gr->moveTo($xmin+0.5/$dpi,$ymin+0.5/$dpi); $gr->lineTo($xmax-0.5/$dpi,$ymin+0.5/$dpi,'black',10); $gr->lineTo($xmax-0.5/$dpi,$ymax-0.5/$dpi,'black',10); $gr->lineTo($xmin+0.5/$dpi,$ymax-0.5/$dpi,"black",10); $gr->lineTo($xmin+0.5/$dpi,$ymin+0.5/$dpi,'black',10); #border around kite ^^^^^^^^^ BEGIN_TEXT $base_line_width $BCENTER \{ image( insertGraph($gr), width=>800, height=>800, tex_size=>800 ) \} $ECENTER $PAR END_TEXT sub PP{ my $x = $_[0]; my $y = $_[1]; my $z = $_[2]; #translation $x = $x - $xo; $y = $y - $yo; $z = $z - $zo; #first rotation - about z-axis #$x1 = $x * $cosThetaAboutZ - $y * $sinThetaAboutZ ; #$y1 = $y *$cosThetaAboutZ +$x *$sinThetaAboutZ ; #second rotation - about x-axis #$y2 = $y1 * $cosThetaAboutX - $z * $sinThetaAboutX ; #$z2 = $z *$cosThetaAboutX + $y1 *$sinThetaAboutX ; #$x2 = $x1; #third - spin about z2 #$x3 = $x2 * $cosThetaAboutZ2 - $y2 * $sinThetaAboutZ2 ; #$y3 = $y2 *$cosThetaAboutZ2 +$x2 *$sinThetaAboutZ2 ; $x3 = $M11*$x+$M12*$y +$M13*$z ; $y3 = $M21*$x+$M22*$y +$M23*$z ; $z2 =$M31*$x+$M32*$y +$M33*$z ; #projecting on the paper $x = $paper_distance * $x3/$z2; $y = $paper_distance * -1 *$y3/$z2; if ($_[3]==1){ $gr->moveTo($x,$y); } if ($_[3]==2){ $private_width = $width; if ($private_width <0){ $private_width = int(abs($private_width * ($hyp / $z2)**3)); } $gr->lineTo($x,$y,$color,$private_width); } if($_[3]==3){ $gr->fillRegion([$x,$y,$color]); } } TEXT($END_ONE_COLUMN); ENDDOCUMENT(); # This should be the last executable line in the problem.