public void TestHere() { Geometry.Vector2D pos = new Geometry.Vector2D(); if (pos.x < General.Map.Config.LeftBoundary || pos.x > General.Map.Config.RightBoundary || pos.y > General.Map.Config.TopBoundary || pos.y < General.Map.Config.BottomBoundary) { Logger.WriteLogLine("failed to start test at position due to odd position, testing in general"); TestAtSkill(General.Map.ConfigSettings.TestSkill); return; } // Create thing General.Map.UndoRedo.CreateUndo("Testing at position"); Map.Thing t = General.Map.Map.CreateThing(); if (t != null) { General.Settings.ApplyDefaultThingSettings(t); t.Type = 1; // set to player FIXME TODO HARDCODED THIS SUX t.UpdateConfiguration(); if (General.Map.Renderer2D != null && General.Map.Renderer2D is Rendering.Renderer2D && General.Editing.Mode is Editing.ClassicMode) { Rendering.Renderer2D renderer2D = (Rendering.Renderer2D)General.Map.Renderer2D; if (renderer2D != null) { t.Move(renderer2D.DisplayToMap( new Geometry.Vector2D( General.MainWindow.Display.RelativeMousePosition.X, General.MainWindow.Display.RelativeMousePosition.Y ))); } } else { t.Move(General.Map.VisualCamera.Position); t.Rotate(General.Map.VisualCamera.AngleXY - Geometry.Angle2D.PI); } // Snap to map format accuracy t.SnapToAccuracy(); TestAtSkill(General.Map.ConfigSettings.TestSkill); General.Map.UndoRedo.WithdrawUndo(); } else { General.Map.UndoRedo.WithdrawUndo(); Logger.WriteLogLine("failed to start test at position due to null t, testing in general"); TestAtSkill(General.Map.ConfigSettings.TestSkill); return; } } // public void TestHere()
/// <summary> /// This returns Z on the plane at X, Y /// </summary> public float GetZ(Vector2D pos) { return((-offset - Vector2D.DotProduct(normal, pos)) / normal.z); }
// Constructor public Line2D(float x1, float y1, float x2, float y2) { this.v1 = new Vector2D(x1, y1); this.v2 = new Vector2D(x2, y2); }
// This tests if the line intersects with the given line coordinates public static bool GetIntersection(Vector2D v1, Vector2D v2, float x3, float y3, float x4, float y4) { float u_ray, u_line; return(GetIntersection(v1, v2, x3, y3, x4, y4, out u_ray, out u_line)); }
// Constructor public Line2D(Vector2D v1, float x2, float y2) { this.v1 = v1; this.v2 = new Vector2D(x2, y2); }
// Constructor public Line2D(float x1, float y1, Vector2D v2) { this.v1 = new Vector2D(x1, y1); this.v2 = v2; }
public float GetNearestOnLine(Vector2D p) { return(Line2D.GetNearestOnLine(v1, v2, p)); }
// Constructor public Line2D(Vector2D v1, Vector2D v2) { this.v1 = v1; this.v2 = v2; }
public float GetSideOfLine(Vector2D p) { return(Line2D.GetSideOfLine(v1, v2, p)); }
public float GetDistanceToLineSq(Vector2D p, bool bounded) { return(Line2D.GetDistanceToLineSq(v1, v2, p, bounded)); }
// This returns the perpendicular vector by simply making a normal public Vector2D GetPerpendicular() { Vector2D d = GetDelta(); return(new Vector2D(-d.y, d.x)); }
// This returns the coordinates at a specific position on the line public static Vector2D GetCoordinatesAt(Vector2D v1, Vector2D v2, float u) { // Calculate and return intersection offset return(new Vector2D(v1.x + u * (v2.x - v1.x), v1.y + u * (v2.y - v1.y))); }
// This returns the offset coordinates on the line nearest to the given coordinates public static float GetNearestOnLine(Vector2D v1, Vector2D v2, Vector2D p) { // Calculate and return intersection offset return(((p.x - v1.x) * (v2.x - v1.x) + (p.y - v1.y) * (v2.y - v1.y)) / GetLengthSq(v2.x - v1.x, v2.y - v1.y)); }
// This returns the shortest distance from given coordinates to line public static float GetDistanceToLine(Vector2D v1, Vector2D v2, Vector2D p, bool bounded) { return((float)Math.Sqrt(GetDistanceToLineSq(v1, v2, p, bounded))); }
// This tests on which side of the line the given coordinates are // returns < 0 for front (right) side, > 0 for back (left) side and 0 if on the line public static float GetSideOfLine(Vector2D v1, Vector2D v2, Vector2D p) { // Calculate and return side information return((p.y - v1.y) * (v2.x - v1.x) - (p.x - v1.x) * (v2.y - v1.y)); }