public void Dimensionals() { Length a = new Length(1); Length b = new Length(); b["cm"] = 50; Length c = a+b; Assert.AreEqual(c["mm"], 1500); c = a * 1.2; Assert.AreEqual(c["m"], 1.2); }
/// <summary> /// Default constructor. /// </summary> public Extrusion() : base() { Scale = 1; Travel = new Length(1); }
public void ExpectUnitException() { Length a = new Length(1); a["invalid"] = 42; }
/// <summary> /// Initialize the point with a unitless vector. /// </summary> public Point(Vector vec) { _val = new Length[] {new Length(vec.X), new Length(vec.Y), new Length(vec.Z)}; }
/// <summary> /// Initialization constructor. /// </summary> /// <param name="x"> The x coordinate. </param> /// <param name="y"> The y coordinate. </param> /// <param name="z"> The z coordinate. </param> public Point(Length x, Length y, Length z) { _val = new Length[]{x, y, z}; }
/// <summary> /// Initialization constructor. /// Uses the default units. /// </summary> /// <param name="x"> The x coordinate. </param> /// <param name="y"> The y coordinate. </param> /// <param name="z"> The z coordinate. </param> public Point(double x, double y, double z) { _val = new Length[]{new Length(x), new Length(y), new Length(z)}; }
/// <summary> /// Default constructor. /// Sets the coordinates to the origin. /// </summary> public Point() { _val = new Length[]{new Length(), new Length(), new Length()}; }
/// <summary> /// Parses a string containing a point definition of the form [x,y,z] in default units. /// </summary> public void Parse(string valString) { if (!valString.StartsWith("[") || !valString.EndsWith("]")) throw new Exception("Vector literals should be surrounded by []"); var comps = valString.Substring(1, valString.Length - 2).Split(','); if (comps.Length != 3) throw new Exception("Vector literals should have 3 comma-separated components"); for (int i = 0; i < 3; i++) { _val[i] = new Length(double.Parse(comps[i])); } }