mat3 outerProduct(vec3 c, vec3 r);
Computes the outer product between two vectors, which is a matrix.
c
- The column vector (vec3
) to be used for the outer product.r
- The row vector (vec3
) to be used for the outer product.mat3
- A 3x3 matrix resulting from the outer product between c
and r
.The outer product between two vectors is defined as follows:
outerProduct(c, r) = [c.x * r.x, c.x * r.y, c.x * r.z;
c.y * r.x, c.y * r.y, c.y * r.z;
c.z * r.x, c.z * r.y, c.z * r.z]
This function allows creating a matrix from two vectors by using one as the column and the other as the row.
vec3 c = vec3(1.0, 2.0, 3.0);
vec3 r = vec3(4.0, 5.0, 6.0);
mat3 m = outerProduct(c, r);
This will create a matrix m
with the following values:
m = [ 4.0, 5.0, 6.0;
8.0, 10.0, 12.0;
12.0, 15.0, 18.0 ]