-
-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* began implementation of UI font size scaling
- Loading branch information
1 parent
875f5ff
commit 74cfdb5
Showing
3 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
fxgl-entity/src/test/kotlin/com/almasb/fxgl/physics/box2d/common/Mat33Test.kt
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,76 @@ | ||
/* | ||
* FXGL - JavaFX Game Library. The MIT License (MIT). | ||
* Copyright (c) AlmasB ([email protected]). | ||
* See LICENSE for details. | ||
*/ | ||
|
||
package com.almasb.fxgl.physics.box2d.common | ||
|
||
import com.almasb.fxgl.core.math.Vec3 | ||
import org.hamcrest.CoreMatchers.* | ||
import org.hamcrest.MatcherAssert.* | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
/** | ||
* @author Ben Highgate ([email protected]) | ||
*/ | ||
class Mat33Test { | ||
|
||
@Test | ||
fun `Matrix mul vector`() { | ||
val mat = Mat33() | ||
|
||
mat.ex.set(3f, 4f, 2f) | ||
mat.ey.set(6f, 2f, 5f) | ||
mat.ez.set(4f, 3f, 3f) | ||
|
||
val v = Vec3(2f, 1f, 4f) | ||
|
||
// [ 3 6 4 ] x [ 2 ] = [ 28 ] | ||
// [ 4 2 3 ] [ 1 ] [ 22 ] | ||
// [ 2 5 3 ] [ 4 ] [ 21 ] | ||
|
||
val out = Vec3() | ||
|
||
Mat33.mulToOutUnsafe(mat, v, out) | ||
|
||
assertThat(out, `is`(Vec3(28f, 22f, 21f))) | ||
} | ||
|
||
@Test | ||
fun `Solve Ax = b`() { | ||
val A = Mat33() | ||
A.ex.set(3.0f, 4.0f, 2.0f) | ||
A.ey.set(6.0f, 2.0f, 5.0f) | ||
A.ez.set(4.0f, 3.0f, 3.0f) | ||
|
||
val b = Vec3(28.0f, 22.0f, 21.0f) | ||
val out = Vec3() | ||
|
||
// [ 3 6 4 ] x [ 2 ] = [ 28 ] | ||
// [ 4 2 3 ] [ 1 ] [ 22 ] | ||
// [ 2 5 3 ] [ 4 ] [ 21 ] | ||
|
||
A.solve33ToOut(b, out) | ||
|
||
assertEquals(2.0f, out.x, 0.0001f) | ||
assertEquals(1.0f, out.y, 0.0001f) | ||
assertEquals(4.0f, out.z, 0.0001f) | ||
} | ||
|
||
@Test | ||
fun `Symmetrical Invert`() { | ||
val A = Mat33() | ||
A.ex.set(3.0f, 4.0f, 2.0f) | ||
A.ey.set(6.0f, 2.0f, 5.0f) | ||
A.ez.set(4.0f, 3.0f, 3.0f) | ||
|
||
val b = Mat33() | ||
A.getSymInverse33(b) | ||
|
||
assertThat(b.ex, `is`(Vec3(-3.0f, -6.0f, 10.0f))) | ||
assertThat(b.ey, `is`(Vec3(-6.0f, -7.0f, 15.0f))) | ||
assertThat(b.ez, `is`(Vec3(10.0f, 15.0f, -30.0f))) | ||
} | ||
} |
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