Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Side by Side Diff: third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp

Issue 2545473002: TransformationMatrix::inverse should use multiplication instead of division (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2009 Torch Mobile, Inc. 3 * Copyright (C) 2009 Torch Mobile, Inc.
4 * Copyright (C) 2013 Google Inc. All rights reserved. 4 * Copyright (C) 2013 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 result[2][2] = tmp1[1]; 490 result[2][2] = tmp1[1];
491 result[2][3] = -tmp3[1]; 491 result[2][3] = -tmp3[1];
492 result[3][0] = -tmp0[0]; 492 result[3][0] = -tmp0[0];
493 result[3][1] = tmp2[0]; 493 result[3][1] = tmp2[0];
494 result[3][2] = -tmp1[0]; 494 result[3][2] = -tmp1[0];
495 result[3][3] = tmp3[0]; 495 result[3][3] = tmp3[0];
496 #else 496 #else
497 // Calculate the adjoint matrix 497 // Calculate the adjoint matrix
498 adjoint(matrix, result); 498 adjoint(matrix, result);
499 499
500 double rdet = 1 / det;
501
500 // Scale the adjoint matrix to get the inverse 502 // Scale the adjoint matrix to get the inverse
501 for (int i = 0; i < 4; i++) 503 for (int i = 0; i < 4; i++)
502 for (int j = 0; j < 4; j++) 504 for (int j = 0; j < 4; j++)
503 result[i][j] = result[i][j] / det; 505 result[i][j] = result[i][j] * rdet;
504 #endif 506 #endif
505 return true; 507 return true;
506 } 508 }
507 509
508 // End of code adapted from Matrix Inversion by Richard Carling 510 // End of code adapted from Matrix Inversion by Richard Carling
509 511
510 // Perform a decomposition on the passed matrix, return false if unsuccessful 512 // Perform a decomposition on the passed matrix, return false if unsuccessful
511 // From Graphics Gems: unmatrix.c 513 // From Graphics Gems: unmatrix.c
512 514
513 // Transpose rotation portion of matrix a, return b 515 // Transpose rotation portion of matrix a, return b
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 decomposition.translateZ, decomposition.scaleX, decomposition.scaleY, 1933 decomposition.translateZ, decomposition.scaleX, decomposition.scaleY,
1932 decomposition.scaleZ, decomposition.skewXY, decomposition.skewXZ, 1934 decomposition.scaleZ, decomposition.skewXY, decomposition.skewXZ,
1933 decomposition.skewYZ, decomposition.quaternionX, 1935 decomposition.skewYZ, decomposition.quaternionX,
1934 decomposition.quaternionY, decomposition.quaternionZ, 1936 decomposition.quaternionY, decomposition.quaternionZ,
1935 decomposition.quaternionW, decomposition.perspectiveX, 1937 decomposition.quaternionW, decomposition.perspectiveX,
1936 decomposition.perspectiveY, decomposition.perspectiveZ, 1938 decomposition.perspectiveY, decomposition.perspectiveZ,
1937 decomposition.perspectiveW); 1939 decomposition.perspectiveW);
1938 } 1940 }
1939 1941
1940 } // namespace blink 1942 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698