# 3 x 4 Matrix

This topic is 3939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

would this function be correct when multipling a vector (Point p) by a 3 x 4 matrix.
   public Point convert(Point p, double[][] matrix) {
Point result = new Point();
result.x = matrix[0][0] * p.x +
matrix[0][1] * p.y +
matrix[0][2] * p.z +
matrix[0][3];

result.y = matrix[1][0] * p.x +
matrix[1][1] * p.y +
matrix[1][2] * p.z +
matrix[1][3];

result.z = matrix[2][0] * p.x +
matrix[2][1] * p.y +
matrix[2][2] * p.z +
matrix[2][3];

return result;
}


[Edited by - staticVoid2 on January 7, 2008 6:12:15 AM]

##### Share on other sites
Close:
   public Point convert(Point p, double[][] matrix) {      Point result = new Point();      result.x = matrix[0][0] * p.x +                 matrix[0][1] * p.y +                 matrix[0][2] * p.z +                 matrix[0][3];      result.y = matrix[1][0] * p.x +                 matrix[1][1] * p.y +                 matrix[1][2] * p.z +                 matrix[1][3];      result.z = matrix[2][0] * p.x +                 matrix[2][1] * p.y +                 matrix[2][2] * p.z +                 matrix[2][3];      return result;   }
When writing these sorts of functions it can help to write out an example. e.g.:
[ 00 01 02 03 ][ x ]   [ x' ][ 10 11 12 13 ][ y ] = [ y' ][ 20 21 22 23 ][ z ]   [ z' ]

##### Share on other sites
I know - I realized at the last minute the mistake I made. thanx

##### Share on other sites
I know - I realized at the last minute the mistake I made. thanx

##### Share on other sites
Correct me if I'm wrong, but iirc you cannot really multiply 3x4 matrix with a 3 element vector (at least not in the way you presented, you could right-multiply a 3 element row vector by a 3x4 matrix).

While in the current context (geometric transformation of a point) jyk's formula is correct, it's correct only because it assumes an extension of the 3-element vector [x,y,z] to the 4-element vector [x,y,z,1].

##### Share on other sites
Quote:
 Original post by MorrandirWhile in the current context (geometric transformation of a point) jyk's formula is correct, it's correct only because it assumes an extension of the 3-element vector [x,y,z] to the 4-element vector [x,y,z,1].
Extending a 3-element vector with an understood w of 1 or 0 (and, similarly, extending a 3x4 or 4x3 matrix with an understood row or column of identity) is a very common shortcut, so I didn't really feel it necessary to point out in my post that the operation in question was technically undefined.

Still, I suppose it was worth clarifying for the OP (although his use of a specialized 'point' class suggested to me that he understood what he was doing, geometrically speaking :).

##### Share on other sites
yeh, when you multiply the displacement vector in the matrix by 1 and then add it to the axis vectors you will get the translated point - but in this function it makes no difference - technically its not a matrix multiplication but it doesn't need to be.

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 13
• 53
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632967
• Total Posts
3009553
• ### Who's Online (See full list)

There are no registered users currently online

×