public void Vector2ToStringTest() { string separator = CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator; CultureInfo enUsCultureInfo = new CultureInfo("en-US"); Vector2D <float> v1 = new Vector2D <float>(2.0f, 3.0f); string v1str = v1.ToString(); string expectedv1 = string.Format(CultureInfo.CurrentCulture , "<{1:G}{0} {2:G}>" , new object[] { separator, 2, 3 }); Assert.Equal(expectedv1, v1str); string v1strformatted = v1.ToString("c", CultureInfo.CurrentCulture); string expectedv1formatted = string.Format(CultureInfo.CurrentCulture , "<{1:c}{0} {2:c}>" , new object[] { separator, 2, 3 }); Assert.Equal(expectedv1formatted, v1strformatted); string v2strformatted = v1.ToString("c", enUsCultureInfo); string expectedv2formatted = string.Format(enUsCultureInfo , "<{1:c}{0} {2:c}>" , new object[] { enUsCultureInfo.NumberFormat.NumberGroupSeparator, 2, 3 }); Assert.Equal(expectedv2formatted, v2strformatted); string v3strformatted = v1.ToString("c"); string expectedv3formatted = string.Format(CultureInfo.CurrentCulture , "<{1:c}{0} {2:c}>" , new object[] { separator, 2, 3 }); Assert.Equal(expectedv3formatted, v3strformatted); }
public void ToStringExample() { var vector = new Vector2D(); var actual = vector.ToString(); Assert.AreEqual("{0,0}", actual); vector.X = 1; vector.Y = 2; actual = vector.ToString(); Assert.AreEqual("{1,2}", actual); }
/// <summary> /// If the tile is null and not walkable, create a new one /// </summary> public void CreateTileVertex() { if (tileVertex == null && isWalkable) { tileVertex = new Vertex(position.ToString(), this); } }
//--------------------------------------------------------------------------------------------------------- /// <summary> /// Открытие контекстного меню /// </summary> /// <param name="sender">Источник события</param> /// <param name="args">Аргументы события</param> //--------------------------------------------------------------------------------------------------------- private void OnButtonMenu_Click(Object sender, RoutedEventArgs args) { ButtonMenu.ContextMenu.IsOpen = true; if (VectorCache != Vector2D.Zero) { miPaste.Header = "Вставить (" + VectorCache.ToString("F1") + ")"; } }
public void ToStringAndParse() { Vector2D vector = new Vector2D(0.0123, 9.876); string s = vector.ToString(); Vector2D parsedVector = Vector2D.Parse(s); Assert.AreEqual(vector, parsedVector); }
public void PointToStringAndFromString() { var v = new Vector2D(2.23f, 3.45f); string pointString = v.ToString(); Assert.AreEqual(v, new Vector2D(pointString)); Assert.Throws <Vector2D.InvalidNumberOfComponents>(() => new Vector2D("0.0")); }
/// ToString of BaseTile, returns position of Tile. public override string ToString() { if (tower != null) { Console.WriteLine(tower.GetType()); } return(pos.ToString()); }
public static Vector2D GetDirection() { IMyCubeBlock reference = P.gridTerminalSystem.GetBlockWithName("MainScript") as IMyCubeBlock; Vector3D dirActual3D = reference.WorldMatrix.GetDirectionVector(Base6Directions.Direction.Forward); Vector2D dirActual = Vector2D.Normalize(Util.Vector3DToVector2D(dirActual3D)); Echo("ActualNoNormalized: " + Util.Vector3DToVector2D(dirActual3D)); Screen.AddText("Direction Forward", dirActual.ToString()); return(dirActual); }
public void TestEquals() { Vector2D v0 = new Vector2D(678.0, 234.8); Vector2D v1 = new Vector2D(678.0, 234.8); Vector2D v2 = new Vector2D(67.0, 234.8); Vector2D v3 = new Vector2D(678.0, 24.8); Assert.IsTrue(v0.Equals(v0)); Assert.IsTrue(v0.Equals(v1)); Assert.IsFalse(v0.Equals(v2)); Assert.IsFalse(v0.Equals(v3)); Assert.IsFalse(v0.Equals(v0.ToString())); }
public IntersectionNotFound(Vector2D position) : base(position.ToString()) {}
public void ToStringTest() { Vector2D a = new Vector2D(1, 2); Assert.IsNotNull(a.ToString()); }
public string ToString() { return(("Pair2D(" + A.ToString() + ", " + B.ToString()) + ")"); }
public void ToStringTest() { var vector = new Vector2D(1, 4.33); Assert.AreEqual("X: 1,00 Y: 4,33", vector.ToString()); }
public void PointToStringAndFromString() { var v = new Vector2D(2.23f, 3.45f); string pointString = v.ToString(); Assert.AreEqual(v, new Vector2D(pointString)); Assert.Throws<Vector2D.InvalidNumberOfComponents>(() => new Vector2D("0.0")); }
public override string ToString() { return(vec.ToString()); }
public void TestToString() { CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture; try { Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); Vector2D a = new Vector2D(1.23, 2.34); Assert.AreEqual("(1,23, 2,34)", a.ToString()); } finally { Thread.CurrentThread.CurrentCulture = originalCulture; } }
public IntersectionNotFound(Vector2D position) : base(position.ToString()) { }
static void Main(string[] args) { // set up a simple configuration that logs on the console. XmlConfigurator.Configure(); try { _log.Info("Pic.Factory2D.Test.exe starting..."); // testing Sharp3D.Math.Core.Matrix3D Transform2D transf0 = Transform2D.Translation(new Vector2D(10.0, 10.0)) * Transform2D.Rotation(45.0); Vector2D pt0 = transf0.transform(new Vector2D(100.0, 100.0)); _log.Info(pt0.ToString()); Transform2D transf1 = transf0.Inverse(); Vector2D pt1 = transf1.transform(pt0); _log.Info(pt1.ToString()); // instantiate factory1 PicFactory factory0 = new PicFactory(); factory0.AddPoint(PicGraphics.LT.LT_CUT, 0, 0, new Vector2D(0.0, 0.0)); factory0.AddSegment(PicGraphics.LT.LT_CUT, 0, 0, new Vector2D(50.0, 50.0), new Vector2D(100.0, 100.0)); factory0.AddSegment(PicGraphics.LT.LT_CUT, 0, 0, new Vector2D(-100.0, 100.0), new Vector2D(100.0, -100.0)); factory0.AddArc(PicGraphics.LT.LT_CUT, 0, 0, new Vector2D(50.0, 50.0), 50.0 * Math.Sqrt(2.0), 0.0, 360.0); factory0.AddArc(PicGraphics.LT.LT_CUT, 0, 0, new Vector2D(75.0, 75.0), 25.0 * Math.Sqrt(2.0), 0.0, 360.0); factory0.AddNurb(PicGraphics.LT.LT_CUT, 0, 0); _log.Debug(factory0.ToString()); // get bounding box + draw using (PicVisitorBoundingBox visitor = new PicVisitorBoundingBox()) { factory0.ProcessVisitor(visitor); _log.Info(visitor.Box.ToString()); // save as image string filePath = Path.Combine(Path.GetTempPath(), "PicImage0.jpeg"); PicGraphicsImage picImage = new PicGraphicsImage(); picImage.ImageSize = new System.Drawing.Size(512, 512); Box2D box = visitor.Box; box.AddMargin(5); picImage.DrawingBox = box; factory0.Draw(picImage); picImage.SaveAs(filePath); _log.Debug("File path = " + filePath); _log.Debug("Path = " + Path.Combine(Environment.SystemDirectory, "mspaint.exe")); System.Diagnostics.Process.Start(Path.Combine(Environment.SystemDirectory, "mspaint.exe"), filePath); } // output to dxf file Pic.Factory2D.PicVisitorDxfOutput dxfOutputVisitor = new Pic.Factory2D.PicVisitorDxfOutput(); factory0.ProcessVisitor(dxfOutputVisitor); // load dxf file PicFactory factory1 = new PicFactory(); PicLoaderDxf loaderDxf = new PicLoaderDxf(factory1); loaderDxf.Load(@"K:\Codesion\PicSharp\Samples\F1034.EV.DXF"); loaderDxf.FillFactory(); // save as image // get bounding box + draw using (PicVisitorBoundingBox visitor1 = new PicVisitorBoundingBox()) { factory1.ProcessVisitor(visitor1); _log.Info(visitor1.Box.ToString()); string filePath1 = Path.Combine(Path.GetTempPath(), "PicImage1.jpeg"); PicGraphicsImage picImage1 = new PicGraphicsImage(); picImage1.ImageSize = new System.Drawing.Size(512, 512); Box2D box1 = visitor1.Box; box1.AddMargin(5); picImage1.DrawingBox = box1; factory1.Draw(picImage1); picImage1.SaveAs(filePath1); _log.Debug("File path = " + filePath1); _log.Debug("Path = " + Path.Combine(Environment.SystemDirectory, "mspaint.exe")); System.Diagnostics.Process.Start(Path.Combine(Environment.SystemDirectory, "mspaint.exe"), filePath1); } // instantiate factory2 PicFactory factory2 = new PicFactory(); PicBlock block = factory2.AddBlock(factory0); factory2.AddBlockRef(block, new Vector2D(0.0, 0.0), 0.0); factory2.AddBlockRef(block, new Vector2D(400.0, 0.0), 0.0); factory2.AddBlockRef(block, new Vector2D(0.0, 400.0), 0.0); factory2.AddBlockRef(block, new Vector2D(400.0, 400.0), 45.0); // get bounding box of factory2 using (PicVisitorBoundingBox visitor = new PicVisitorBoundingBox()) { factory2.ProcessVisitor(visitor); _log.Info(visitor.Box.ToString()); // save as image string filePath = Path.Combine(Path.GetTempPath(), "PicImage2.jpeg"); PicGraphicsImage picImage = new PicGraphicsImage(); picImage.ImageSize = new System.Drawing.Size(512, 512); Box2D box = visitor.Box; box.AddMargin(5); picImage.DrawingBox = box; factory2.Draw(picImage); picImage.SaveAs(filePath); _log.Debug("File path = " + filePath); _log.Debug("Path = " + Path.Combine(Environment.SystemDirectory, "mspaint.exe")); System.Diagnostics.Process.Start(Path.Combine(Environment.SystemDirectory, "mspaint.exe"), filePath); } // compute area PicFactory factory3 = new PicFactory(); factory3.AddSegment(PicGraphics.LT.LT_CUT, 0, 0, new Vector2D(-100.0, -100.0), new Vector2D(100.0, -100.0)); factory3.AddSegment(PicGraphics.LT.LT_CUT, 0, 0, new Vector2D(100.0, -100.0), new Vector2D(100.0, 100.0)); factory3.AddSegment(PicGraphics.LT.LT_CUT, 0, 0, new Vector2D(100.0, 100.0), new Vector2D(-100.0, 100.0)); factory3.AddSegment(PicGraphics.LT.LT_CUT, 0, 0, new Vector2D(-100.0, 100.0), new Vector2D(-100.0, -100.0)); PicToolArea picToolArea = new PicToolArea(); factory3.ProcessTool(picToolArea); _log.Info(string.Format("Area of factory3 is {0}", picToolArea.Area)); _log.Info("Pic.Factory2D.Test.exe finishing..."); } catch (Exception ex) { _log.Error(ex.ToString()); } }
/** * Constructs a new property. */ public Property(string _name, Vector2D _value) { name = normalize(_name); value = _value.ToString(); valid = true; }