Bläddra i källkod

Added functionality to shorten and extend vector4 and vector3

Christian Wolfgang 5 år sedan
förälder
incheckning
8888dd9055
2 ändrade filer med 10 tillägg och 0 borttagningar
  1. 5 0
      math32/vector3.go
  2. 5 0
      math32/vector4.go

+ 5 - 0
math32/vector3.go

@@ -678,3 +678,8 @@ func (v *Vector3) AlmostEquals(other *Vector3, tolerance float32) bool {
 	}
 	return false
 }
+
+// Vector4 returns a new Vector4 based on this vector and the provided w value.
+func (v *Vector3) Vector4(w float32) *Vector4 {
+	return &Vector4{X: v.X, Y: v.Y, Z: v.Z, W: w}
+}

+ 5 - 0
math32/vector4.go

@@ -642,3 +642,8 @@ func (v *Vector4) AlmostEquals(other *Vector4, tolerance float32) bool {
 	}
 	return false
 }
+
+// Vector3 returns a new Vector3 based on this vector, without the w value.
+func (v *Vector4) Vector3() *Vector3 {
+	return &Vector3{X: v.X, Y: v.Y, Z: v.Z}
+}