public void Vector3ToStringTest() { string separator = CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator; CultureInfo enUsCultureInfo = new CultureInfo("en-US"); Vector3D <float> v1 = new Vector3D <float>(2.0f, 3.0f, 3.3f); string v1str = v1.ToString(); string expectedv1 = string.Format(CultureInfo.CurrentCulture , "<{1:G}{0} {2:G}{0} {3:G}>" , separator, 2, 3, 3.3); Assert.Equal(expectedv1, v1str); string v1strformatted = v1.ToString("c", CultureInfo.CurrentCulture); string expectedv1formatted = string.Format(CultureInfo.CurrentCulture , "<{1:c}{0} {2:c}{0} {3:c}>" , separator, 2, 3, 3.3); Assert.Equal(expectedv1formatted, v1strformatted); string v2strformatted = v1.ToString("c", enUsCultureInfo); string expectedv2formatted = string.Format(enUsCultureInfo , "<{1:c}{0} {2:c}{0} {3:c}>" , enUsCultureInfo.NumberFormat.NumberGroupSeparator, 2, 3, 3.3); Assert.Equal(expectedv2formatted, v2strformatted); string v3strformatted = v1.ToString("c"); string expectedv3formatted = string.Format(CultureInfo.CurrentCulture , "<{1:c}{0} {2:c}{0} {3:c}>" , separator, 2, 3, 3.3); Assert.Equal(expectedv3formatted, v3strformatted); }
private Vector3D CalcColorVector(TextBox oldColorBox, TextBox newColorBox) { Vector3D colorVector = ConvertPoint3D(oldColorBox.Text); if (colorVector == null) { throw new GeometryException("Test program error"); } colorVector.Normalize(); byte R = (byte)(colorVector.X * 255.0); byte G = (byte)(colorVector.Y * 255.0); byte B = (byte)(colorVector.Z * 255.0); oldColorBox.Text = colorVector.ToString(); oldColorBox.BackColor = Color.FromArgb(R, G, B); MouseRecognitionModule.RotateSingleVector(colorVector, SinCosW); newColorBox.Text = colorVector.ToString(); R = (byte)(colorVector.X * 255.0); G = (byte)(colorVector.Y * 255.0); B = (byte)(colorVector.Z * 255.0); newColorBox.BackColor = Color.FromArgb(R, G, B); oldColorBox.ForeColor = newColorBox.ForeColor = Color.White; return(colorVector); }
public void ToStringTest() { Vector3D v = new Vector3D(0.1, 0.2, 0.3); Assert.AreEqual(string.Format("{0}, {1}, {2}", 0.1, 0.2, 0.3), v.ToString()); Assert.AreEqual("0.1, 0.2, 0.3", v.ToString("G", UsFormat)); Assert.AreEqual("0,1, 0,2, 0,3", v.ToString("G", EsFormat)); Assert.AreEqual("0,1, 0,2, 0,3", v.ToString("G", DeFormat)); }
public void ToStringExample() { var vector = new Vector3D(); var actual = vector.ToString(); Assert.AreEqual("{0,0,0}", actual); vector.X = 1; vector.Y = 2; vector.Z = 7; actual = vector.ToString(); Assert.AreEqual("{1,2,7}", actual); }
public void ToString2Test() { var v = new Vector3D(1.1234, 2.2345, 3.3456); var vs = v.ToString(4); Assert.True(vs == "(1.1234, 2.2345, 3.3456)"); }
private void _engine_ObjectMotion(object sender, ObjectEventArgs e) { this.Dispatcher.Invoke((Action)(() => { Transform3DGroup TransformGroup = new Transform3DGroup(); Vector3D offsetVector = new Vector3D(e.Obj.Position.X * -1, e.Obj.Position.Y, e.Obj.Position.Z); TranslateTransform3D TranslateTransform = new TranslateTransform3D(offsetVector * ViewportScalingFactor); TransformGroup.Children.Add(TranslateTransform); e.Obj.Bounds = TranslateTransform.TransformBounds(_gameObjects[e.Obj].Content.Bounds); int objIndex = this.hlxViewport.Children.IndexOf(_gameObjects[e.Obj]); this.hlxViewport.Children[objIndex].Transform = TransformGroup; if (e.Obj.TrackCollisions) { foreach (var gameObject in _gameObjects.Keys.Where(x => x != e.Obj && x.Model.IsGameWorld == false).ToList()) { if (gameObject.Bounds.IntersectsWith(e.Obj.Bounds)) { _engine.PuckCollision(gameObject); #if DEBUG using (StreamWriter w = File.AppendText("log.txt")) { Startup.Log("Collision:", w); Startup.Log("Puck Location: " + offsetVector.ToString(), w); Startup.Log("Collided with: " + gameObject.ObjectType + " at " + gameObject.Position.ToString(), w); } #endif } } } })); }
static void Main(string[] args) { string filePath = @"D:\GitHub\StackBuilder\Sources\Samples\testFGA.csv"; using (FileStream fs = File.OpenRead(filePath)) { ExporterCSV_TechBSA exporter = new ExporterCSV_TechBSA(); Vector3D dimCase = Vector3D.Zero; Vector3D dimPallet = Vector3D.Zero; double weightCase = 0.0, weightPallet = 0.0, maxPalletHeight = 0.0; List <BoxPosition> boxPositions = new List <BoxPosition>(); bool hasInterlayerBottom = false, hasInterlayerTop = false, hasInterlayersMiddle = false, alternateLayers = false; ExporterCSV_TechBSA.Import(fs, ref boxPositions, ref dimCase, ref weightCase, ref dimPallet, ref weightPallet, ref maxPalletHeight, ref alternateLayers, ref hasInterlayerBottom, ref hasInterlayerTop, ref hasInterlayersMiddle); Console.WriteLine("Box positions:"); foreach (var bp in boxPositions) { Console.WriteLine(bp.ToString()); } Console.WriteLine($"DimCase:{dimCase.ToString()}"); Console.WriteLine($"WeightCase:{weightCase}"); Console.WriteLine($"DimPallet:{dimPallet.ToString()}"); Console.WriteLine($"WeightPallet:{weightPallet}"); Console.WriteLine($"InterlayerBottom:{hasInterlayerBottom}"); Console.WriteLine($"InterlayerTop:{hasInterlayerTop}"); Console.WriteLine($"InterlayerMiddle:{hasInterlayersMiddle}"); } }
public static Vector2D GetPosition() { Vector3D posActual = P.gridTerminalSystem.GetBlockWithName("MainScript").GetPosition(); Screen.AddText("Position: ", posActual.ToString()); return(Util.Vector3DToVector2D(posActual)); }
/// <summary> /// Queries the current task for suggestions on linear and angular velocities, and sets up thrusters and gyros accordingly. /// </summary> /// <param name="elapsed">How many seconds elapsed since the last update.</param> /// <returns>True if all tasks have been completed.</returns> public override bool Update(TimeSpan elapsed) { if (CurrentTask == null) //if there is nothing to do, drift { return(true); //report that we are done } else //there is something to do { elapsedTime = elapsed; Velocities = Controller.GetShipVelocities(); Mass = Controller.CalculateShipMass(); // current velocities Vector3D LinearV = Velocities.LinearVelocity; Vector3D TargetAngularV = Velocities.AngularVelocity; //task can always set respective velocities to 0 to avoid linear and/or angular motion Controller.DampenersOverride = CurrentTask.DampenersOverride; //query the task. bool done = CurrentTask.Update(this, ref LinearV, ref TargetAngularV); Log?.Invoke($"Task {CurrentTask.ToString()}\nDone: {done}\nLinear {LinearV.ToString()}\nAngular {TargetAngularV.ToString()}"); //whether its done or not, apply changes to thrust/rotation SetRotationVelocity(TargetAngularV, CurrentTask.Reference, CurrentTask.ReferenceForward, CurrentTask.ReferenceUp); SetThrustVector(LinearV); return(done); } }
void Main(string argument) { Vector3D origin = new Vector3D(0, 0, 0); if (argument == null || argument == "") { GridTerminalSystem.GetBlocksOfType <IMyRemoteControl>(list); var remote = list[0]; origin = remote.GetPosition() + (500000 * remote.WorldMatrix.Forward); //Me.TerminalRunArgument = origin.ToString(); //Update as Api Changed Me.TryRun(origin.ToString()); return; } else { Vector3D.TryParse(argument, out origin); } GridTerminalSystem.GetBlocksOfType <IMyRemoteControl>(list); if (list.Count > 0) { var remote = list[0] as IMyRemoteControl; remote.ClearWaypoints(); remote.AddWaypoint(origin, "Origin"); remote.SetAutoPilotEnabled(true); } }
public void Print() { int n = 0; System.Console.Out.WriteLine("慣性パラメータ名:" + name); System.Console.Out.WriteLine("慣性パラメータブロック:"); for (int i = 0; i < MAX_BLOCK; i++) { InertiaBlock ib; if ((ib = block[i]) != null) { System.Console.Out.WriteLine(" No." + i + " " + ib.ToString()); n++; } } System.Console.Out.WriteLine("慣性パラメータブロック数:" + n); System.Console.Out.WriteLine("m=" + m + "[kg] "); System.Console.Out.WriteLine("C.G.=" + cg.ToString() + "[m] "); System.Console.Out.WriteLine("Ixx=" + ixx + "[kg・m2] "); System.Console.Out.WriteLine("Iyy=" + iyy + "[kg・m2] "); System.Console.Out.WriteLine("Izz=" + izz + "[kg・m2] "); System.Console.Out.WriteLine("Ixy=" + ixy + "[kg・m2] "); System.Console.Out.WriteLine("Iyz=" + iyz + "[kg・m2] "); System.Console.Out.WriteLine("Izx=" + izx + "[kg・m2] "); System.Console.Out.WriteLine("角運動量の係数行列"); InertiaMat.Print(); System.Console.Out.WriteLine("角運動量の係数行列の逆行列"); InertiaInvMat.Print(); }
void AnalyzeText() { #region аспознаем текст, добавляем узлы TextRange doc = new TextRange(mainWindow.textEdit.Document.ContentStart, mainWindow.textEdit.Document.ContentEnd); mainWindow.structuralModel.nodes.Clear(); mainWindow.Dispatcher.Invoke(() => { mainWindow.modelVisual3D.Children.Clear(); }); var lines = doc.Text.Split('\n'); foreach (var l in lines) { var words = l.Split(" ".ToCharArray()); switch (words[0]) { case "node": try { var x = Convert.ToSingle(words[1]); var y = Convert.ToSingle(words[2]); var z = Convert.ToSingle(words[3]); var n = mainWindow.structuralModel.AddNode(x, y, z); n.xt = n.x + 1.0; n.yt = n.y; n.zt = n.z; if (words[4] == "cs") { n.xt = Convert.ToSingle(words[5]); n.yt = Convert.ToSingle(words[6]); n.zt = Convert.ToSingle(words[7]); } } catch (Exception) { } break; default: break; } } foreach (var n in mainWindow.structuralModel.nodes) { Vector3D pos = new Vector3D(n.x, n.y, n.z); mainWindow.AddSphere(n.x, n.y, n.z, 0.2); mainWindow.AddCs(pos, new Vector3D(n.xt, n.yt, n.zt)); mainWindow.Add3DLabel(pos, pos.ToString()); } #endregion }
public void ToStringAndFromString() { var v = new Vector3D(2.23f, 3.45f, 0.59f); string vectorAsString = v.ToString(); Assert.AreEqual(v, new Vector3D(vectorAsString)); }
/// <summary> /// Serializes the HomeLocation into a string ready to be saved. /// </summary> /// <returns></returns> public string ProduceSaveData() { var o_string = ""; o_string += shipConnectorID.ToString() + main_delimeter; o_string += stationConnectorID.ToString() + main_delimeter; o_string += stationConnectorPosition.ToString() + main_delimeter; o_string += stationConnectorForward.ToString() + main_delimeter; o_string += stationConnectorUpGlobal.ToString() + main_delimeter; o_string += stationConnectorUpLocal.ToString() + main_delimeter; o_string += stationConnectorLeft.ToString() + main_delimeter; //if(stationGridID.Contains(";") || stationGridID.Contains(main_delimeter) || stationGridID.Contains("#")) //{ // stationGridID = "Name contained bad char"; //} o_string += stationGridID.ToString() + main_delimeter; o_string += stationConnectorSize.ToString() + main_delimeter; o_string += landingSequencesToString() + main_delimeter; //Matrix transformMat = Matrix. o_string += ProduceSavedNames() + main_delimeter; foreach (var arg in arguments) { o_string += arg + arg_delimeter; } o_string = o_string.Substring(0, o_string.Length - 1); return(o_string); }
void WriteEcho() { Echo("Running.\nConfigs:"); foreach (string s in configurations.Keys) { if (s == currentConfig) { Echo(s + '*'); } else { Echo(s); } } Echo(offset.ToString("0.00")); if (leaderMatrix == MatrixD.Zero) { Echo("No messages received."); } else if (calculateMissingTicks && runtime - updated > maxMissingScriptTicks) { Echo($"Weak signal, message received {runtime - updated} ticks ago."); } if (autoStop && prevControl) { Echo("Cockpit is under control."); } }
private string subtract3DVectorsExample() { // <SnippetSubtract3DVectorsExample_csharp> // Subtracts two 3-D Vectors using the Subtract method and - // Declaring vector1 and initializing x,y,z values Vector3D vector1 = new Vector3D(20, 30, 40); // Declaring vector2 without initializing x,y,z values Vector3D vector2 = new Vector3D(); // Assigning values to vector2 vector2.X = 45; vector2.Y = 70; vector2.Z = 80; // Subtracting vectors using overload - operator Vector3D vectorResult1 = new Vector3D(); vectorResult1 = vector1 - vector2; // vectorResult1 is equal to (-25, -40, -40) // Subtracting vectors using static Subtract method Vector3D vectorResult2 = new Vector3D(); vectorResult2 = Vector3D.Subtract(vector1, vector2); // vector2 is equal to (-25, -40, -40) // </SnippetSubtract3DVectorsExample_csharp> string stringResults = "vectorResult1: " + vectorResult1.ToString(); stringResults = stringResults + " vectorResult2: " + vectorResult2.ToString(); return(stringResults); }
private static void Main() { //DaanLib.Datastructures.LinkedList<int> list = new DaanLib.Datastructures.LinkedList<int>(); //DaanLib.Maths.Vector2D v = new DaanLib.Maths.Vector2D(5, 10); //Matrix m = new Matrix(v); //Console.WriteLine(m); //Console.WriteLine(Matrix.Identity(5)); Vector2D vec = new Vector2D(1, 3); string vecS = vec.ToString(); Vector2D vec2 = new Vector2D(vecS); Console.WriteLine(vec2); Vector3D vec3 = new Vector3D(1, 3, 5); vecS = vec3.ToString(); Vector3D vec4 = new Vector3D(vecS); Console.WriteLine(vec4); Console.ReadKey(); }
public void ToString3Test() { var v = new Vector3D(1.1234, 2.2345, 3.3456); var vs = v.ToString(1e-2); Assert.True(vs == "(1.12, 2.23, 3.35)"); }
private static void SolveMathExpression(string[] args) { if (args[1] == "*" && IsValidOperand(args[0]) && VerifyNumericOperand(args[2], "A number")) { double m = Convert.ToDouble(args[2]); _c = args[0] == "A" ? _a * m : _b * m; } else if (args[0] == "A" || args[0] == "B") { if (args[0] == "A") { AddSubstractVector(args[1], ref _a, ref _b); } else { AddSubstractVector(args[1], ref _b, ref _a); } } else { throw new InvalidOperandException(args[3], "A or B"); } Console.WriteLine(_c.ToString()); }
public void Save() { ini.Set("General", "AbortDistance", AbortDistance); ini.Set("General", "ScanningDistance", ScanningDistance); ini.Set("General", "MaxSpeed", MaxSpeed); ini.Set("General", "ActionTimeout", ActionTimeout); ini.Set("General", "TransmitTag", TransmitTag); ini.Set("General", "Dock", DockLocation.ToString()); ini.Set("General", "DockApproach", DockApproachVector.ToString()); ini.Set("General", "GrinderGroup", GrinderGroup); if (Vector3D.IsZero(GrinderApproach)) { ini.Delete("General", "GrinderLocation"); ini.Delete("General", "GrinderApproach"); } else { ini.Set("General", "GrinderLocation", GrinderLocation.ToString()); ini.Set("General", "GrinderApproach", GrinderApproach.ToString()); } foreach (var kv in Approaches) { string data = string.Join("\n", kv.Value.Select <Vector3D, string>((v) => $"GPS:waypoint:{v.X:F3}:{v.Y:F3}:{v.Z:F3}:")); ini.Set("Approach", kv.Key, data); } ini.Set("Runtime", "CurrentState", State_Machine?.CurrentState ?? ""); ini.Set("Runtime", "TargetLocation", TargetLocation.ToString()); ini.Set("Runtime", "ChosenApproach", ChosenApproach); ini.Set("Runtime", "ApproachIndex", ApproachIndex); ini.Set("Runtime", "TargetEntityID", TargetEntityID); Storage = ini.ToString(); }
internal void AddObject(Vector3D position, String name) { TextBox newItem = new TextBox(); newItem.Text = name + "\t" + position.ToString(); this.ObjectList.Children.Add(newItem); }
static void Main(string[] args) { Vector3D u = new Vector3D(0, 3, 4); Vector3D v = new Vector3D(0, 4, -3); Point3D a = new Point3D(10, 12, 15); Point3D b = a + u; // Point + Vector = Point Vector3D w = b - a; // Point - Point = Vector Vector3D t = u + v; // Vector + Vector = Vector double angle = Vector3D.AngleBetween(u, v); Vector3D cross = Vector3D.CrossProduct(u, v); double dot = Vector3D.DotProduct(u, v); Vector3D normal = cross; normal.Normalize(); Vector3D scaled = normal * 10; Console.WriteLine("u:\t" + u.ToString()); Console.WriteLine("v:\t" + v.ToString()); Console.WriteLine("w:\t" + w.ToString()); Console.WriteLine("a:\t" + a.ToString()); Console.WriteLine("b:\t" + b.ToString()); Console.WriteLine("angle:\t" + angle.ToString()); Console.WriteLine("cross:\t" + cross.ToString()); Console.WriteLine("dot:\t" + dot.ToString()); Console.WriteLine("normal:\t" + normal.ToString()); Console.WriteLine("scaled:\t" + scaled.ToString()); Console.ReadLine(); }
Program() { _guns = new List <IMyUserControllableGun>(); _controllers = new List <IMyRemoteControl>(); GridTerminalSystem.GetBlocksOfType(_guns); GridTerminalSystem.GetBlocksOfType(_controllers); _currentControl = _controllers.FirstOrDefault(c => c.IsFunctional); if (_currentControl == null) { return; } if (string.IsNullOrEmpty(Storage)) { if (!Vector3D.TryParse(Storage, out _origin)) { _origin = _currentControl.GetPosition(); } } else { _origin = _currentControl.GetPosition(); Storage = _origin.ToString(); } _weaponAngle = Math.Cos(MathHelperD.ToRadians(WEAPON_ANGLE_LIMIT)); }
void WriteEcho() { Echo("Running.\n" + settings.followerSystemId + "." + settings.followerId + "\nConfigs:"); foreach (string s in settings.configs.Value.Keys) { if (s == currentConfig) { Echo(s + '*'); } else { Echo(s); } } Echo(offset.ToString("0.00")); if (leaderMatrix == MatrixD.Zero) { Echo("No messages received."); } else if (settings.calculateMissingTicks.Value && runtime - updated > settings.maxMissingScriptTicks.Value) { Echo($"Weak signal, message receved {runtime - updated} ticks ago."); } if (settings.autoStop.Value && prevControl) { Echo("Cockpit is under control."); } if (obstacleOffset.HasValue) { Echo("Obstacle Detected! Stopping the ship."); } }
public override string ToString() { return( "{{Min:" + Min.ToString() + " Max:" + Max.ToString() + "}}" ); }
} //GetQuatKey() protected bool UpdateVecKey(string key, Vector3D v) { bool err = false; // error return RemoveKey(key); // remove the key (if it exists) err = AddKey(key, v.ToString()); // output as a string return(err); } // UpdateVecKey()
public override string ToString() { return( "{Normal:" + Normal.ToString() + " D:" + D.ToString() + "}" ); }
public void ToStringTest_WhenVectorIsConvertedToString_ThenResultIsVectorInAString() { var vec = new Vector3D(5.0, 7.0, 9.0); var output = vec.ToString(); Assert.Equal("Vector3D(5, 7, 9)", output); }
/// <summary> /// Returns a <see cref="String"/> representation of this <see cref="BoundingSphereD"/> in the format: /// {Center:[<see cref="Center"/>] Radius:[<see cref="Radius"/>]} /// </summary> /// <returns>A <see cref="String"/> representation of this <see cref="BoundingSphereD"/>.</returns> public override string ToString() { return( "{Center:" + Center.ToString() + " Radius:" + Radius.ToString() + "}" ); }
public void ToStringAndParse() { Vector3D vector = new Vector3D(0.0123, 9.876, -2.3); string s = vector.ToString(); Vector3D parsedVector = Vector3D.Parse(s); Assert.AreEqual(vector, parsedVector); }
/// <summary> /// Takes 2 joints, A & B, and returns the of angle between ray(AB) and /// the ground's normal vector (Assuming Kinect is level). /// A\ | /// \ | /// B\ | /// \x| /// Ground _ _ _ \|_ _ _ Ground /// /// Example Usage: /// The following returns the extension angle of skel's right elbow... /// jointAngle(skel.Joints[JointType.ShoulderRight], /// skel.Joints[JointType.ElbowRight], /// skel.Joints[JointType.WristRight]) /// </summary> public static float boneNormalOffset(Joint a, Joint b) { Vector3D va = new Vector3D(a.Position.X, a.Position.Y, a.Position.Z); Vector3D vb = new Vector3D(b.Position.X, b.Position.Y, b.Position.Z); Vector3D vn = new Vector3D(b.Position.X, b.Position.Y + 0.5, b.Position.Z); Vector3D vba = new Vector3D(); vba = Vector3D.Subtract(va, vb); Vector3D vbn = new Vector3D(); vbn = Vector3D.Subtract(vn, vb); if (debug) { Console.Out.WriteLine("va: " + va.ToString()); Console.Out.WriteLine("vb: " + vb.ToString()); Console.Out.WriteLine("vn: " + vn.ToString()); Console.Out.WriteLine("vba: " + vba.ToString()); Console.Out.WriteLine("vbn: " + vbn.ToString()); Console.Out.WriteLine("NormalOffset(vba,vbn): " + Vector3D.AngleBetween(vba, vbn)); } return (float)Vector3D.AngleBetween(vba, vbn); }
/// <summary> /// Takes 2 joints, A & B, and returns the Distance(A<->B) as a float. /// /// Example Usage: /// The following returns the distance traveled between to frames: /// jointDistance(skel_before.Joints[JointType.ShoulderCenter], /// skel_after.Joints[JointType.ShoulderCenter]) /// /// The following returns the distance between two wrists in one frame: /// jointDistance(skel.Joints[JointType.WristRight], /// skel.Joints[JointType.WristLeft]); /// </summary> public static float jointDistanceZAxis(Joint a, Joint b) { Vector3D va = new Vector3D(0, 0, a.Position.Z); Vector3D vb = new Vector3D(0, 0, b.Position.Z); Vector3D vba = new Vector3D(); vba = Vector3D.Subtract(va, vb); if (debug) { Console.Out.WriteLine("va: " + va.ToString()); Console.Out.WriteLine("vb: " + vb.ToString()); Console.Out.WriteLine("vba: " + vba.ToString()); Console.Out.WriteLine("Distance(vba,vbc): " + vba.Length); } return (float)vba.Length; }
/// <summary> /// Takes 3 joints, A, B, & C, and returns the Angle(ABC) as a float. /// A /// / /// / /// /B_ _ _C /// /// Example Usage: /// The following returns the extension angle of skel's right elbow... /// jointAngle(skel.Joints[JointType.ShoulderRight], /// skel.Joints[JointType.ElbowRight], /// skel.Joints[JointType.WristRight]) /// </summary> public static float jointAngle(Joint a, Joint b, Joint c) { Vector3D va = new Vector3D(a.Position.X, a.Position.Y, a.Position.Z); Vector3D vb = new Vector3D(b.Position.X, b.Position.Y, b.Position.Z); Vector3D vc = new Vector3D(c.Position.X, c.Position.Y, c.Position.Z); Vector3D vba = new Vector3D(); vba = Vector3D.Subtract(va, vb); Vector3D vbc = new Vector3D(); vbc = Vector3D.Subtract(vc, vb); if (debug) { Console.Out.WriteLine("va: " + va.ToString()); Console.Out.WriteLine("vb: " + vb.ToString()); Console.Out.WriteLine("vc: " + vc.ToString()); Console.Out.WriteLine("vba: " + vba.ToString()); Console.Out.WriteLine("vbc: " + vbc.ToString()); Console.Out.WriteLine("Angle(vba,vbc): " + Vector3D.AngleBetween(vba, vbc)); } return (float)Vector3D.AngleBetween(vba, vbc); }
private void process_data(Vector3D acc) { _readingIndex++; double len = acc.Length; if (_max_value < len) { _max_value = len; } _update_max_value_lbl(); _add_new_point("acc_x", _readingIndex, acc.x); _add_new_point("acc_y", _readingIndex, acc.y); _add_new_point("acc_z", _readingIndex, acc.z); _add_new_point("v_len", _readingIndex, len + _length_offset); if (chk_raw_data.Checked) { _rtb_append(_readingIndex + " -> " + acc.ToString() + "\n"); } }
public void TestEquals() { Vector3D v0 = new Vector3D(678.0, 234.8, -123.987); Vector3D v1 = new Vector3D(678.0, 234.8, -123.987); Vector3D v2 = new Vector3D(67.0, 234.8, -123.987); Vector3D v3 = new Vector3D(678.0, 24.8, -123.987); Vector3D v4 = new Vector3D(678.0, 234.8, 123.987); Assert.IsTrue(v0.Equals(v0)); Assert.IsTrue(v0.Equals(v1)); Assert.IsFalse(v0.Equals(v2)); Assert.IsFalse(v0.Equals(v3)); Assert.IsFalse(v0.Equals(v4)); Assert.IsFalse(v0.Equals(v0.ToString())); }
public void ToStringAndParse() { Vector3D vector = new Vector3D(0.0123, 9.876, -2.3); string s = vector.ToString(); Vector3D parsedVector = Vector3D.Parse(s); Assert.AreEqual(vector, parsedVector); }
public void ToStringAndFromString() { var v = new Vector3D(2.23f, 3.45f, 0.59f); string vectorAsString = v.ToString(); Assert.AreEqual(v, new Vector3D(vectorAsString)); }
public void TestToString() { CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture; try { Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); Vector3D a = new Vector3D(1.23, 2.34, 3.45); Assert.AreEqual("(1,23, 2,34, 3,45)", a.ToString()); } finally { Thread.CurrentThread.CurrentCulture = originalCulture; } }