Преглед на файлове

Merge pull request #172 from wolfgarnet/vector-shorten-and-reduce

Added functionality to shorten and extend vector4 and vector3
Daniel Salvadori преди 5 години
родител
ревизия
391d397cdd
променени са 2 файла, в които са добавени 10 реда и са изтрити 0 реда
  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}
+}