Modify Gram-Schmitt process
authorTheSaminator <TheSaminator@users.noreply.github.com>
Wed, 8 Jun 2022 20:39:18 +0000 (16:39 -0400)
committerTheSaminator <TheSaminator@users.noreply.github.com>
Wed, 8 Jun 2022 20:39:18 +0000 (16:39 -0400)
src/commonMain/kotlin/net/starshipfights/game/ai/ai_optimization_util.kt

index da20d90057b63c8638e50d5f586cfc305e7065c6..cb3749026ad2b48ea5c83cbaeed86d2d423f8410 100644 (file)
@@ -39,10 +39,9 @@ fun Random.nextOrthonormalBasis(size: Int): List<VecN> {
        
        val orthogonalBasis = mutableListOf<VecN>()
        while (orthogonalBasis.size < size) {
-               val vector = nextUnitVector(size)
-               var orthogonal = vector
+               var orthogonal = nextUnitVector(size)
                for (prevVector in orthogonalBasis)
-                       orthogonal -= (vector project prevVector)
+                       orthogonal -= (orthogonal project prevVector)
                
                if (!orthogonal.isNullVector)
                        orthogonalBasis.add(orthogonal)