# Put your transformation matrices successively it the matrices A, B, and C.
# Easily create more if desired and add to the code.
# For this example, we want to reflect across the line y = (rise/run)x
# or perhaps said as "the line created by the vector <5,6> through the origin"
# This requires one to rotate counterclockwise by the angle -theta found using trig
# and then flipping easily across the x-axis which is well known
# and then rotating back clockwise by the angle theta.
# Since sine is an odd function, then this has been implememted below by fixing the
# correct +/- on the s portions.
# The illustration below takes the letter "J" and puts is somewhere originally in BLUE.
# The rotation by -theta shows up in RED
# The subsequent reflection across the x-axis shows up in GREEN
# The rotation back by theta shows up finally in BLACK
# If given a vector to refect across, the vector will be given as <run, rise>
theta = atan(rise/run)
c = cos(theta)
s = sin(theta)
A = matrix([[c, s],[-s, c]])
B = matrix([[1, 0],[0, -1]])
C = matrix([[c, -s],[s, c]])
# Enter your data points below with x in first and y in second in order
pts = matrix([[2.6, 2.8, 3, 3.2, 3.4, 3, 3, 2.9, 2.8, 2.7],
[ 1, 1, 1, 1, 1, 0.8, 0.6, 0.5, 0.4, 0.5]])
n = pts.ncols()
ans1 = A*pts
ans2 = B*ans1
ans3 = C*ans2
T = C*B*A
G = line([(-run,-rise),(run,rise)],color='yellow')
for k in range(n):
G += point((pts[k],pts[k]),color='blue')
G += point((ans1[k],ans1[k]),color='red')
G += point((ans2[k],ans2[k]),color='green')
G += point((ans3[k],ans3[k]),color='black')
G += line([(ans3[k],ans3[k]),(pts[k],pts[k])],alpha=0.4,color='lightgray')