Fix vector projection
authorTheSaminator <thesaminator@users.noreply.github.com>
Fri, 24 Jun 2022 19:47:17 +0000 (15:47 -0400)
committerTheSaminator <thesaminator@users.noreply.github.com>
Fri, 24 Jun 2022 19:47:17 +0000 (15:47 -0400)
src/commonMain/kotlin/net/starshipfights/game/ai/ai_optimization_util.kt

index 2cde6c204aea46aba6040c99e8f3826de50d3687..688128bc631a5841673f781afa1437aacfd863eb 100644 (file)
@@ -79,7 +79,7 @@ infix fun VecN.dot(other: VecN): Double {
 }
 
 infix fun VecN.project(onto: VecN): VecN {
-       return this * ((this dot onto) / (this dot this))
+       return onto * ((this dot onto) / (onto dot onto))
 }
 
 operator fun VecN.plus(other: VecN): VecN {