aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/ExtensionMethods.cs
blob: d2400784142a55cda47b12c1b3c4318667fe7e3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System.Numerics;

namespace vkChess
{
	public static class ExtensionMethods {
		public static Vector3 ParseVec3 (string str) {
			if (string.IsNullOrEmpty (str))
				return new Vector3();
			string[] components = str.Substring(1, str.Length - 2).Split (',');
			if (components.Length != 3)
				throw new System.Exception ("Vector3 Parse Error, expecting 3 components.");
			return new Vector3(
				float.Parse (components[0]),
				float.Parse (components[1]),
				float.Parse (components[2])
			);
		}
	}
}