On Apr 28, 10:20 pm, Hans Petter Langtangen <
h...@simula.no> wrote:
> Hi, I dont't understand what your are trying to plot. Can you define it
> precisely in mathematical terms? To me, plotting a "transformable 2x2
> matrix in 2-space" does not map to any type of plot I've heard about...
Hello Hans,
I think the confusion might be in the word "transformable". By this I
just meant a Python object that I could perform matrix math with, for
example multiplying it by another matrix to achieve a rotation.
So, I want to take an arbitrary 2x2 matrix, plot its core vectors onto
a Cartesian plane, multiply the original matrix by another (let's say
a shear or a rotation) and plot the core vectors of the result onto
the plane in a different colour.
I imagine it looking something like this:
def plot_2x2_matrix(matrix):
point_0 = [0,0] # origin
point_1 = (matrix[0][0] , matrix[0][1]) # column 1
point_2 = (matrix[1][0] , matrix[1][1]) # column 2
point_3 = (matrix[0][0] + matrix[1][0] , matrix[0][1] + matrix[1]
[1])
# point_3 is the sum of column 1 & 2
axis.plot(point_0, point_1) # vector 1
axis.plot(point_0, point_2) # vector 2
axis.plot(point_0, point_3) # combined vector
axis.plot(point_1, point_3)
axis.plot(point_2, point_3)
# last two finish off the "box"
def 2x2_transformation(matrix, transformation):
result = matrix * transformation
plot_2x2_matrix(matrix)
plot_2x2_matrix(result)
def main():
matrix_a = [[1,3] , [2,4]] # an arbitrary matrix
rotate_90 = [[0, 1] , [-1, 0]] # transformation
# I presume there's a good (NumPy) type for storing matrices
2x2_transformation(matrix_a, rotate_90)
What I'm looking for are which objects and methods I need to do this.
And then I want to do it all over again for a 3x3 matrix on a 3
dimensional axis.
Hope this has clarified things. Thanks for the feedback and any
guidance you can provide!
David