Exemplo n.º 1
0
		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);
		}
Exemplo n.º 2
0
		/// <summary>
		/// Default constructor.
		/// </summary>
		public Extrusion() : base()
		{
			Scale = 1;
			Travel = new Length(1);
		}
Exemplo n.º 3
0
		public void ExpectUnitException()
		{
			Length a = new Length(1);
			a["invalid"] = 42;
		}
Exemplo n.º 4
0
		/// <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)};
		}
Exemplo n.º 5
0
		/// <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};
		}
Exemplo n.º 6
0
		/// <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)};
		}			
Exemplo n.º 7
0
		/// <summary>
		/// Default constructor.
		/// Sets the coordinates to the origin.
		/// </summary>
		public Point()
		{
			_val = new Length[]{new Length(), new Length(), new Length()};
		}
Exemplo n.º 8
0
		/// <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]));
			}
		}