Permalink
Browse files

Modify and return a Vector with one new component

  • Loading branch information...
1 parent 0328723 commit 694ddf056a01eb8ea0331de17a047da88682be2d @mstevenson committed Apr 8, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 Vector3Extensions.cs
View
@@ -11,4 +11,19 @@ public static float LargestComponent (this Vector3 v)
return v.x > v.y ? (v.x > v.z ? v.x : (v.y > v.z ? v.y : v.z)) : (v.y > v.z ? v.y : (v.x > v.z ? v.x : v.z));
}
+ public static Vector3 WithX (this Vector3 vec, float value)
+ {
+ return new Vector3 (value, vec.y, vec.z);
+ }
+
+ public static Vector3 WithY (this Vector3 vec, float value)
+ {
+ return new Vector3 (vec.x, value, vec.z);
+ }
+
+ public static Vector3 WithZ (this Vector3 vec, float value)
+ {
+ return new Vector3 (vec.x, vec.y, value);
+ }
+
}

0 comments on commit 694ddf0

Please sign in to comment.