Below, two pentagons are shown. The goal is to choose the correct linear transformations and in the correct order so that the blue/green pentagon is transformed to the red pentagon.
from sage.misc.html import HtmlFragment
def record_answer(ansVals): pretty_print( HtmlFragment('<input type=hidden size=15 name="sageAnswer" id ="sageAnswer" value="%s"><input type=hidden name="previous_sageAnswer" id = "previous_sageAnswer" value="">'%(ansVals,) ) )
Aexact = matrix([[0.75,0],[1.5,1]])
N=2
choices = ['Identity', 'Reflect x-axis', 'Reflect y-axis', 'Rotate Origin', 'Skew to the right if above and to the left if below','Skew to the left if above and to the right if below', 'Skew out vertically', 'Skew in vertically','Horizontal Contraction','Horizontal Expansion','Vertical Contraction','Vertical Expansion']
@interact
def _(transform1=('Select:',list(choices)),transform2=('Select:',list(choices)),transform3=('Select:',list(choices)) ):
def getA(transform):
A = identity_matrix(N)
if transform=='Reflect x-axis':
A = matrix(QQ,[[1,0],[0,-1]])
if transform=='Reflect y-axis':
A = matrix(QQ,[[-1,0],[0,1]])
if transform=='Rotate Origin':
A = matrix(QQ,[[-1,0],[0,-1]])
if transform=='Skew to the right if above and to the left if below':
A = matrix(QQ,[[1,1.5],[0,1]])
if transform=='Skew to the left if above and to the right if below':
A = matrix(QQ,[[1,-1.5],[0,1]])
if transform=='Skew out vertically':
A = matrix(QQ,[[1,0],[1.5,1]])
if transform=='Skew in vertically':
A = matrix(QQ,[[1,0],[-1.5,1]])
if transform=='Horizontal Contraction':
A = matrix(QQ,[[0.75,0],[0,1]])
if transform=='Horizontal Expansion':
A = matrix(QQ,[[1.25,0],[0,1]])
if transform=='Vertical Contraction':
A = matrix(QQ,[[1,0],[0,0.75]])
if transform=='Vertical Expansion':
A = matrix(QQ,[[1,0],[0,1.25]])
return A
A1 = identity_matrix(N)
A2 = identity_matrix(N)
A3 = identity_matrix(N)
A1 = getA(transform1)
A2 = getA(transform2)
A3 = getA(transform3)
BigA = A3*A2*A1
StartBox = line2d([(0,0),(0,1)],thickness=10)+line2d([(0,1),(1,2)],thickness=10)+line2d([(1,2),(2,1)],thickness=10)+line2d([(2,1),(2,0)],thickness=10)+line2d([(2,0),(0,0)],thickness=10)
BoxCorners = matrix([[0, 0, 1, 2, 2],[0, 1, 2, 1, 0]])
NewCorners = (BigA*BoxCorners).transpose() # switch result matrix to rows for easier extraction of A*B columns.
EndBox = Graphics()
Goal = (Aexact*BoxCorners).transpose() # this is the final answer that is being sought
GoalBox = Graphics()
for col in range(5):
c1 = NewCorners[Mod(col,5)]
c2 = NewCorners[Mod(col+1,5)]
EndBox += line2d([c1,c2],thickness=5, rgbcolor=(0.5,1,0.5))
g1 = Goal[Mod(col,5)]
g2 = Goal[Mod(col+1,5)]
GoalBox += line2d([g1,g2],thickness=5, rgbcolor=(1,0,0))
show(StartBox+EndBox+GoalBox,aspect_ratio=True)
pretty_print(html('\\['+str(latex(BigA))+' = '+str(latex(A3))+str(latex(A2))+str(latex(A1))+'\\]'))
B = [list(BigA[0]),list(BigA[1])]
record_answer((B))
var jqSave = $.noConflict(true);
jqSave(function () {
sagecell.makeSagecell({
inputLocation: '#sagecell',
template: sagecell.templates.minimal,
autoeval: true,
linked: true,
evalButtonText: 'Start/Restart the Interactive Cell'
});
});
$ = jQuery = jqSave;
When you are comfortable with the coefficients that you have chosen, press
the submit button below.