using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace xmlTools
{
///
/// This class represents a xmlNumberValue. It supports various dimensions separated by spaces. For example a quaternion: 1 -1 1 -1
/// It also includes various functions to work with multi dimensional number xml values
///
public class XmlNumberValue
{
public List myValues = new List(); //include all dimensions of the value
public XmlNumberValue(String myString)
{
String[] values = myString.Split(' ');
foreach (string value in values)
{
this.myValues.Add(XmlConvert.ToDouble(value));
}
}
public XmlNumberValue(List myDimensions)
{
this.myValues = myDimensions;
}
public static XmlNumberValue difference(XmlNumberValue first, XmlNumberValue second)
{
List result = new List();
for (int i = 0; i < first.myValues.Count; i++)
{
result.Add(first.myValues[i] - second.myValues[i]);
}
return new XmlNumberValue(result);
}
public static XmlNumberValue sum(XmlNumberValue first, XmlNumberValue second)
{
List result = new List();
for (int i = 0; i < first.myValues.Count; i++)
{
result.Add(first.myValues[i] + second.myValues[i]);
}
return new XmlNumberValue(result);
}
public override string ToString()
{
String result = "";
for (int i = 0; i < this.myValues.Count - 1; i++)
{
result += XmlConvert.ToString(this.myValues[i]) + " ";
}
result += XmlConvert.ToString(this.myValues[this.myValues.Count - 1]);
return result;
}
}
}