[原FPS]物理引擎/甘雨对狙
This commit is contained in:
1 parent
7d1b33af50
commit
6c0826138f
7 files changed
+308
-31
No files matched your search
@@ -1,5 +1,9 @@
|
||||
package alg
|
||||
|
||||
import (
|
||||
"math"
|
||||
)
|
||||
|
||||
// Vector2 二维向量
|
||||
type Vector2 struct {
|
||||
X float32
|
||||
@@ -13,6 +17,16 @@ type Vector3 struct {
|
||||
Z float32
|
||||
}
|
||||
|
||||
// Vector2Magnitude 二维向量模长
|
||||
func Vector2Magnitude(v *Vector2) float32 {
|
||||
return float32(math.Sqrt(float64(v.X*v.X + v.Z*v.Z)))
|
||||
}
|
||||
|
||||
// Vector3Magnitude 三维向量模长
|
||||
func Vector3Magnitude(v *Vector3) float32 {
|
||||
return float32(math.Sqrt(float64(v.X*v.X + v.Y*v.Y + v.Z*v.Z)))
|
||||
}
|
||||
|
||||
// Vector2Add 二维向量加
|
||||
func Vector2Add(v1 *Vector2, v2 *Vector2) *Vector2 {
|
||||
v3 := new(Vector2)
|
||||
|
||||
Reference in new issue
Block a user