Added geo and gl packages from gogeline and improved documentation.

This commit is contained in:
Marvin Blum
2016-05-03 21:23:50 +02:00
parent 05013370fd
commit 19731dc0e5
15 changed files with 1388 additions and 3 deletions

20
geo/util.go Normal file
View File

@@ -0,0 +1,20 @@
package geo
import (
"math"
)
// Returns the distance between two 2D vectors.
func DistanceVec2(a, b Vec2) float64 {
return math.Sqrt(float64((a.X-b.X)*(a.X-b.X) + (a.Y-b.Y)*(a.Y-b.Y)))
}
// Returns the distance between two 3D vectors.
func DistanceVec3(a, b Vec3) float64 {
return math.Sqrt(float64((a.X-b.X)*(a.X-b.X) + (a.Y-b.Y)*(a.Y-b.Y) + (a.Z-b.Z)*(a.Z-b.Z)))
}
// Returns the distance between two 4D vectors.
func DistanceVec4(a, b Vec4) float64 {
return math.Sqrt(float64((a.X-b.X)*(a.X-b.X) + (a.Y-b.Y)*(a.Y-b.Y) + (a.Z-b.Z)*(a.Z-b.Z) + (a.W-b.W)*(a.W-b.W)))
}