-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
and its equivalen in classes
- Loading branch information
Showing
6 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { mat3FromMat4Transpose } from './mat3FromMat4Transpose'; | ||
import { mat3Inverse } from './mat3Inverse'; | ||
import type { RawMatrix3 } from './RawMatrix3'; | ||
import type { RawMatrix4 } from '../mat4/RawMatrix4'; | ||
|
||
/** | ||
* Create a normal matrix out of a matrix4. | ||
* | ||
* @param matrix A matrix4 | ||
*/ | ||
export function mat3CreateNormalMatrix( m: RawMatrix4 ): RawMatrix3 { | ||
return mat3Inverse( mat3FromMat4Transpose( m ) ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import '../../../tests/matchers/toBeCloseToArray'; | ||
import { mat3CreateNormalMatrix } from '../mat3CreateNormalMatrix'; | ||
import type { RawMatrix3 } from '../RawMatrix3'; | ||
import type { RawMatrix4 } from '../../mat4/RawMatrix4'; | ||
|
||
const rawMatrixLookAtFrom345: RawMatrix4 = [ | ||
0.8574929257125442, 0, -0.5144957554275265, 0, | ||
-0.2910427500435996, 0.824621125123532, -0.48507125007266594, 0, | ||
0.4242640687119285, 0.565685424949238, 0.7071067811865475, 0, | ||
3, 4, 5, 1 | ||
]; | ||
|
||
const rawMatrixLookAtFrom345Normal: RawMatrix3 = [ | ||
0.857, 0.0, -0.514, | ||
-0.291, 0.825, -0.485, | ||
0.424, 0.566, 0.707, | ||
]; | ||
|
||
describe( 'mat3CreateNormalMatrix', () => { | ||
it( 'returns a determinant of the matrix', () => { | ||
const subject = mat3CreateNormalMatrix( rawMatrixLookAtFrom345 ); | ||
expect( subject ).toBeCloseToArray( rawMatrixLookAtFrom345Normal ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters