简体   繁体   中英

python vector * vector------> matrix

In the python computer graphics kit, there is a vec3 type for the representation of three-component vectors, but how can I do the following multiplication:

A three-component vector multiply by its transpose result in a 3*3 matrix, like the following example:

a = vec3(1,1,1)
matrix_m = a * a.transpose()

Anyone knows such a library that can handle multiplying a matrix of dimension 1*3 by another one of dimension 3*1 and result in a matrix of 3*3.

Sorry, I have to clarify a bit more about this. I am talking about matrix math. It is like:

[a0, a1, a2]*[a0, a1, a2]T = [a0*a0, a0*a1, a0*a2; a1*a0, a1*a1, a1*a2;a2*a0, a2*a1, a2*a2]

Maybe I can try write a function myself, it is so straightforward.....

Some vector math software, such as MATLAB, happily keep track of column vectors and row vectors as separate types of things. Python's Numpy doesn't, but does offer numpy.outer(A,B). Unfortunately, the Graphics Kit (I assume you refer to http://cgkit.sourceforge.net/ ) doesn't track rows vs columns, use numpy (which would be huge overkill), or provide a vector x vector --> matrix outer product. It looks like you'll have to write your own function to do that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM