示例#1
0
        public static Vector2 Parse(string text)
        {
            if (text[0] == '(' || text[text.Length - 1] == ')')
            {
                text = text.Substring(1, text.Length - 2);
            }
            string[] tokens = text.Split(',');
            if (tokens.Length != 2)
            {
                tokens = text.Split(' ');
            }
            if (tokens.Length != 2)
            {
                throw new System.FormatException("The input text must contains 2 elements.");
            }
            Number x = Number.Parse(tokens[0]);
            Number y = Number.Parse(tokens[1]);

            return(new Vector2(x, y));
        }
示例#2
0
        public static Quaternion Parse(string text)
        {
            if (text[0] == '(' || text[text.Length - 1] == ')')
            {
                text = text.Substring(1, text.Length - 2);
            }
            string[] tokens = text.Split(',');
            if (tokens.Length != 4)
            {
                tokens = text.Split(' ');
            }
            if (tokens.Length != 4)
            {
                throw new System.FormatException("The input text must contains 4 elements.");
            }
            Number x = Number.Parse(tokens[0]);
            Number y = Number.Parse(tokens[1]);
            Number z = Number.Parse(tokens[2]);
            Number w = Number.Parse(tokens[3]);

            return(new Quaternion(x, y, z, w));
        }