Initial commit

This commit is contained in:
2022-01-20 21:58:50 +08:00
commit b44d41ec66
86 changed files with 5415 additions and 0 deletions

15
internal/util/bunnyhop.go Normal file
View File

@@ -0,0 +1,15 @@
package util
import "edgaru089.ml/go/gl01/internal/util/itype"
func BunnyhopAccelerate(accelDir, prevVel itype.Vec3d, accelVel, maxVel float64) (resultVel itype.Vec3d) {
if accelVel < 1e-4 {
return prevVel
}
projVel := prevVel.Dot(accelDir)
if projVel+accelVel > maxVel {
accelVel = maxVel - projVel
}
return prevVel.Add(accelDir.Normalize().Multiply(accelVel))
}