protected override void Dispose(bool disposing) { base.Dispose(disposing); m_userName = null; m_password = null; m_servername = null; m_tagFilter = null; m_pisdk = null; m_server = null; m_points = null; m_tagKeyMap.Clear(); m_tagKeyMap = null; m_measurements.Clear(); m_measurements = null; if (m_dataThread != null) { m_dataThread.Abort(); m_dataThread = null; } if (m_publishTimer != null) { m_publishTimer.Stop(); m_publishTimer.Elapsed -= m_publishTimer_Tick; m_publishTimer.Dispose(); m_publishTimer = null; } }
public List<LocationOfInterest> GetInterestingLocations(Avatar observer) { List<LocationOfInterest> locationsOfInterest = new List<LocationOfInterest>(); MapTile observerTile = _quest.GetAvatarMapTile(observer); Point observerLocation = _quest.Map.GetMapTileLocation(observerTile); PointList visibleLocations = _quest.Map.GetPointsWithinLineOfSightOf(observerLocation); //// Get a list of all actionable map tiles PointList interestingLocations = _quest.Map.GetActionableMapPoints(observer.Faction); // Filter out interesting locations that are not in the visible set PointList visibleInterestingLocations = interestingLocations.Intersects(visibleLocations); // Create paths to each of these points PathfindingNode observerNode = _quest.Map.GetPathfindingNodeForTile(observerTile); foreach (Point point in visibleInterestingLocations) { PathfindingNode pointNode = _quest.Map.GetPathfindingNodeForLocation(point.X, point.Y); List<PathfindingNode> path = _quest.Map.PathfindingGraph.FindRoute(observerNode, pointNode); if (path != null) { PointList pathSteps = new PointList(); for (int i = 1; i < path.Count; i++) { pathSteps.Add(_quest.Map.GetPointForPathfindingNode(path[i])); } LocationOfInterest interest = new LocationOfInterest(pathSteps); locationsOfInterest.Add(interest); } } return locationsOfInterest; }
public DrawPolygon(int x1, int y1, int x2, int y2) : base() { pointArray = new PointList(); pointArray.Add(new Point(x1, y1)); pointArray.Add(new Point(x2, y2)); Initialize(); }
/// <summary> /// コンストラクタ /// </summary> public Board() { // Vectorの配列を初期化 for (int i = 0; i <= Reversi.MAX_TURNS; i++) { _movablePos[i] = new PointList(); } init_member(); }
public static decimal CalculateCost(PointList permutation) { decimal cost = 0m; for (int i = 0; i < permutation.Count - 1; i++) cost += Point.Distance(permutation[i], permutation[i + 1]); cost += Point.Distance(permutation[permutation.Count - 1], permutation[0]); return cost; }
public MovementTurnStepAction(Avatar actor, PointList stepsToLocation, MapTile interestingLocation=null) : base(false) { _avatar = actor; _stepsToLocation = stepsToLocation; RequiresMovement = true; HasMoreTurns = (_stepsToLocation.Count > 1) ? true : false; // If there are more steps, then we can be used in subsequent turns! AcceptsAvatarFocus = HasMoreTurns; }
override public TurnStepAction FindAction(Avatar currentAvatar, AvatarTurnState avatarTurnState, QuestAnalyzer mapAnalyzer, ChanceProvider chanceProvider) { PointList unwalkedTiles = mapAnalyzer.GetAdjacentUnvisitedLocations(currentAvatar); if (unwalkedTiles.Count <= 0) { return null; } // Just pick the first tile, and see if that opens up any other actions... PointList path = new PointList() { unwalkedTiles[0] }; MovementTurnStepAction action = new MovementTurnStepAction(currentAvatar, path); return action; }
public Piece(){ range = new PointList<RectPoint> (); range.Add (new RectPoint (0, 0)); range.Add (new RectPoint (1, 0)); range.Add (new RectPoint (2, 0)); range.Add (new RectPoint (-1, 0)); range.Add (new RectPoint (-2, 0)); range.Add (new RectPoint (0, 1)); range.Add (new RectPoint (0, 2)); range.Add (new RectPoint (0, -1)); range.Add (new RectPoint (0, -2)); }
private float Area(PointList contour) { int n = contour.Size(); float sA = 0.0f; for (int p = n - 1, q = 0; q < n; p = q++) { Point contourP = contour.Get(p); Point contourQ = contour.Get(q); sA += contourP.GetX() * contourQ.GetY() - contourQ.GetX() * contourP.GetY(); } return sA * 0.5f; }
public void SetFactionWalkedOn(Faction faction, Point point) { PointList factionWalkedOn = null; if (!_tilesWalkedOn.ContainsKey(faction)) { factionWalkedOn = new PointList(); _tilesWalkedOn[faction] = factionWalkedOn; } else { factionWalkedOn = _tilesWalkedOn[faction]; } if (!factionWalkedOn.ContainsLocation(point.X, point.Y)) { factionWalkedOn.Add(point); } }
public override Value Evaluate(FSharpList<Value> args) { PointList points = new PointList(); var input = (args[0] as Value.List).Item; foreach (Value v in input) { Point p = ((Value.Container)v).Item as Point; points.Add(p); } _bsplinecurve = BSplineCurve.by_points(points); return Value.NewContainer(_bsplinecurve); }
private void btnGo_Click(object sender, EventArgs e) { if (cboGraphType.SelectedIndex == 4) selectedPointList = customPointList; if (selectedPointList.Count < 2) return; PointList result = selectedAlgorithm(selectedPointList); displayList(result); displayGraph(result); result.RemoveAt(result.Count - 1); lblCost.Text = TspTest.CalculateCost(result).ToString("#,##0"); }
public static PointList ClosestPair(PointList inputList) { PointList endpoints = inputList.Clone(); List<PointList> vertexChains = new List<PointList>(); while (endpoints.Count > 2) { PairOfPoints closestPair = findClosestPair(forEachPair(endpoints).Where(pair => !inSameVertexChain(pair.A, pair.B, vertexChains))); PointList chainA = findChainWithEndpoint(closestPair.A, vertexChains); PointList chainB = findChainWithEndpoint(closestPair.B, vertexChains); if (chainA != null && chainB != null) { vertexChains.Remove(chainA); vertexChains.Remove(chainB); chainA.Reverse(); vertexChains.Add(new PointList(chainA.Concat(chainB))); endpoints.Remove(closestPair.A); endpoints.Remove(closestPair.B); continue; } if (chainB != null) { closestPair = closestPair.Invert(); chainA = chainB; chainB = null; } if (chainA != null) { chainA.Insert(0, closestPair.B); endpoints.Remove(closestPair.A); continue; } vertexChains.Add(new PointList(new List<Point>() { closestPair.A, closestPair.B })); } if (vertexChains.Count > 1) throw new ApplicationException("More than one vertex chain was obtained."); vertexChains[0].Add(vertexChains[0][0]); return vertexChains[0]; }
public static IEnumerable<PointList> AllPermutations(PointList inputList) { if (inputList.Count < 2) yield return inputList; else foreach (Point p in inputList) { PointList shorterList = new PointList(inputList); shorterList.Remove(p); foreach (PointList permutation in AllPermutations(shorterList)) { PointList newPermutation = new PointList(permutation); newPermutation.Add(p); yield return newPermutation; } } }
public PointList GetAdjacentUnwalkedTiles(Point origin, Faction faction) { PointList list = GetVisibleAdjacentPoints(origin, new PointList()); PointList factionWalkedOnList = new PointList(); if (_tilesWalkedOn.ContainsKey(faction)) { factionWalkedOnList = _tilesWalkedOn[faction]; } for(int i=list.Count-1; i >= 0; i--) { Point point = list[i]; if (factionWalkedOnList.ContainsLocation(point.X, point.Y)) { list.RemoveAt(i); } } return list; }
// Update is called once per frame void OnDrawGizmos() { if (points == null || points.Count < 1) { return; } // ShapePath pointList = new PointList(); // ShapePath if (pointList != null) { shapePath = pointList.GetShapePath(points.ToArray(), rots.ToArray()); for (int i = 0; i < num; i++) { float v = (float)i / num; Vector3 pt; // pt = shapePath.getPointInfoVec3Percent(v); PathVector pv = shapePath.getPathInfo(v); pt = new Vector3(pv.x, pv.y, pv.z); Gizmos.color = color; Gizmos.DrawWireSphere(pt, 0.25f); Quaternion rot = pv.rot; // Gizmos.color = new Color(0, 0, 0, 0.25f); Gizmos.DrawRay(pt, rot * Vector3.up * 2); Gizmos.DrawRay(pt, rot * Vector3.right * 2); Quaternion q2 = GetQuaternionAt(v); Gizmos.color = Color.green; Gizmos.DrawRay(pt, q2 * Vector3.up); Gizmos.color = Color.red; Gizmos.DrawRay(pt, q2 * Vector3.right); } } }
private void Button_Click_5(object sender, RoutedEventArgs e) { if (PointList.Count < 14) { PointList.Add(new Point(99, 36)); PointList.Add(new Point(84, 15.5)); PointList.Add(new Point(61.2, 11.5)); PointList.Add(new Point(51.3, 18.5)); PointList.Add(new Point(44, 8.5)); PointList.Add(new Point(21, 5)); PointList.Add(new Point(0.5, 19.5)); PointList.Add(new Point(79, 24)); PointList.Add(new Point(71.2, 23)); PointList.Add(new Point(63.5, 21.3)); PointList.Add(new Point(39, 17.2)); PointList.Add(new Point(30.8, 16)); PointList.Add(new Point(23, 14.5)); PointList = PointList; } }
/// <summary>画图</summary> public override void Draw(Graphics g) { using (Pen pen = new Pen(PenColor, PenWidth)) { Point[] pts = new Point[PointList.Count]; PointList.CopyTo(pts); g.SmoothingMode = SmoothingMode.AntiAlias; if (pts.Length < 3) { if (pts.Length > 1) { g.DrawLine(pen, pts[0], pts[1]); } } else { g.DrawCurve(pen, pts); } } }
public ActionResult Insert(PointListViewModels model) { string userId = User.Identity.GetUserId(); string userName = User.Identity.GetUserName(); var result = context.PointItems.FirstOrDefault(c => c.Id == model.PointList.PointItemId); var value = new PointList { UserId = userId, UserName = userName, PointItemId = model.PointList.PointItemId, PointItemName = result.Name, Points = model.PointList.Points, Remark = model.PointList.Remark, DateAdded = DateTime.Now }; context.PointLists.Add(value); context.SaveChanges(); return(RedirectToAction("Index", "PointList")); }
/// <summary> /// 绘制主梁的Bolt在Y向上的标注; /// </summary> private void DrawMainPartBoltDimY() { CBeamTopViewSetting beamTopViewSetting = CBeamDimSetting.GetInstance().mTopViewSetting; bool bNeedMainBeamBoltDim = beamTopViewSetting.FindDimValueByName(CBeamTopViewSetting.mstrBolt); if (!bNeedMainBeamBoltDim) { return; } List <CMrDimSet> boltDimSetList = GetMainPartBoltDimSetY(); if (boltDimSetList == null || boltDimSetList.Count == 0) { return; } foreach (CMrDimSet mrDimSet in boltDimSetList) { if (mrDimSet == null || mrDimSet.Count <= 1) { continue; } if (!IsNeedMrDimSetDim(mrDimSet)) { continue; } List <Point> dimPointList = mrDimSet.GetDimPointList(); PointList pointList = new PointList(); foreach (Point point in dimPointList) { pointList.Add(point); } double dimDistance = mrDimSet.mDimDistance; Vector dimVector = mrDimSet.mDimVector; CDimTools.GetInstance().DrawDimensionSet(mViewBase, pointList, dimVector, dimDistance, CCommonPara.mSizeDimPath); } }
public void completeDraw(Angle lat, Angle lon) { //if (World.Settings.CurrentWwTool != this.drawTool) // return; if (State == DrawState.Drawing) { if (Angle.IsNaN(lat)) { return; } Point3d pickPt = new Point3d(); pickPt.X = lon.Degrees; pickPt.Y = lat.Degrees; pickPt.Z = (useTerrain) ? getElevation(lat.Degrees, lon.Degrees) : defaultElev; if (PointList.Count > 0) { List <CustomVertex.PositionColored> newVertexes = getCurveFromPoints(PointList[PointList.Count - 1], pickPt, lineColor); VertexList.AddRange(newVertexes.GetRange(1, newVertexes.Count - 1)); } else { VertexList.Add(Point3d2PositionColored(pickPt, lineColor)); } PointList.Add(pickPt); } List <CustomVertex.PositionColored> lastVertexes = getCurveFromPoints(PointList[PointList.Count - 1], PointList[0], lineColor); VertexList.AddRange(lastVertexes.GetRange(1, lastVertexes.Count - 1)); pcs = new CustomVertex.PositionColored[VertexList.Count]; VertexList.CopyTo(pcs); State = DrawState.Complete; if (OnCompeleted != null) { OnCompeleted(this, new EventArgs()); } }
// Use this for initialization void Start() { randomPoints = new List <Vector3>(); for (int i = 0; i < 5; i++) { randomPoints.Add(new Vector3((i) * 10, Random.Range(-50.0f, 50.0f), Random.Range(-50.0f, 50.0f))); //randomPoints.Add(new Vector3(Random.Range(- 50.0f, 50.0f), Random.Range(- 50.0f, 50.0f), Random.Range(- 50.0f, 50.0f)) * 0.4f); } // BezierCurve3 curve = new THREE.CurvePath(); // Vector3 c = (randomPoints[1] - randomPoints[2]) * -1 + randomPoints[2]; // for (int i = 2; i < randomPoints.Count-1; i++) { // c = (c - randomPoints[i]) * -1 + randomPoints[i]; // THREE.QuadraticBezierCurve3 curveSegment1 = new THREE.QuadraticBezierCurve3(randomPoints[i], c, randomPoints[i + 1]); // curve.add(curveSegment1); // } Vector3 centerPosPre; Vector3 centerPosNext = Vector3.Lerp(randomPoints[1], randomPoints[2], 0.5f); THREE.QuadraticBezierCurve3 curveSegment = new THREE.QuadraticBezierCurve3(randomPoints[0], randomPoints[1], centerPosNext); curve.add(curveSegment); for (int i = 2; i < randomPoints.Count - 1; i++) { centerPosPre = Vector3.Lerp(randomPoints[i - 1], randomPoints[i], 0.5f); centerPosNext = Vector3.Lerp(randomPoints[i], randomPoints[i + 1], 0.5f); THREE.QuadraticBezierCurve3 curveSegment1 = new THREE.QuadraticBezierCurve3(centerPosPre, randomPoints[i], centerPosNext); curve.add(curveSegment1); } // Spline3 spline = new THREE.SplineCurve3(randomPoints); // ShapePath PointList pointList = new PointList(); shapePath = pointList.GetShapePath(randomPoints.ToArray()); }
/// <summary> /// deep copy clone: clones the data only from another given gradient. /// </summary> /// <param name="other"></param> public void CloneDataFrom(ColorGradient other) { _colors = new PointList <ColorPoint>(); foreach (ColorPoint cp in other.Colors) { _colors.Add(new ColorPoint(cp)); } _alphas = new PointList <AlphaPoint>(); foreach (AlphaPoint ap in other.Alphas) { _alphas.Add(new AlphaPoint(ap)); } _gammacorrected = other.Gammacorrected; if (other.Title != null) { _title = other.Title; } _blend = null; SetEventHandlers(); }
public static List <Point> getMeshVerticies(MFnMesh mayaMesh) { PointList verts = new PointList(mayaMesh.numVertices); MPointArray mayaVerts = new MPointArray(); mayaMesh.getPoints(mayaVerts, MSpace.Space.kWorld); foreach (var v in mayaVerts) { if (MGlobal.isZAxisUp) { verts.Add(Point.ByCoordinates(v.x, v.y, v.z)); } else { verts.Add(Point.ByCoordinates(v.x, -v.z, v.y)); } } return(verts); }
public override bool Run(List <InputDefinition> inputs) { try { // // This is an example for selecting two points; change this to suit your needs. // ViewBase view = InputDefinitionFactory.GetView(inputs[0]); PointList points = InputDefinitionFactory.GetPoints(inputs[0]); // // Write your code here; better yet, create private methods and call them from here. // } catch (Exception Exc) { MessageBox.Show(Exc.ToString()); } return(true); }
/// <summary> /// Returns true if it found the points. /// </summary> public static bool LoadPoints(string name) { if (!Directory.Exists(PointIO.FolderPath)) { Directory.CreateDirectory(PointIO.FolderPath); } var pointList = PointIO.Open(Path.Combine(PointIO.FolderPath, name) + ".txt") ?? new PointList(); _currentLoadedPointList = pointList; _currentLoadedName = name; if (PointManager.PointLists.ContainsKey(name)) { PointManager.PointLists[name] = pointList; return(true); } PointManager.PointLists.Add(name, pointList); return(false); }
public StraightRailEle CreateEle(Point pt, Size size, Int16 multiFactor, string text) { Point[] pts = new Point[2]; DrawMultiFactor = multiFactor; objectStaightOp.DrawMultiFactor = multiFactor; pt.Offset(pt.X / DrawMultiFactor - pt.X, pt.Y / DrawMultiFactor - pt.Y); pts[0] = pt; if ((pt.X + Lenght) > size.Width) { pts[0] = new Point(pt.X - lenght, pt.Y); pts[1] = new Point(pt.X, pt.Y); } else { pts[0] = new Point(pt.X, pt.Y); pts[1] = new Point(pt.X + lenght, pt.Y); } PointList.AddRange(pts); this.railText = text; return(this); }
/// <summary> /// 对于正常的左右倾斜梁的下标注; /// </summary> public void DrawXDownDimNormal() { List <Point> downDimPointList = new List <Point>(); foreach (CMrPart mrPart in mMrPartList) { CMrDimSet partDimSet = mrPart.GetBeamDoorFrontViewInfo().GetXDownDimSetNormal(); if (partDimSet != null && partDimSet.Count > 0) { downDimPointList.AddRange(partDimSet.GetDimPointList()); } } CMrPart topBeam = CMrBeamDoorManager.GetInstance().mTopBeam; CMrPart bottomBeam = CMrBeamDoorManager.GetInstance().mBottonBeam; CMrPart leftBeam = CMrBeamDoorManager.GetInstance().mLeftBeam; CMrPart rightBeam = CMrBeamDoorManager.GetInstance().mRightBeam; downDimPointList.Add(topBeam.mLeftTopPoint); downDimPointList.Add(bottomBeam.mLeftBottomPoint); downDimPointList.Add(topBeam.mRightTopPoint); downDimPointList.Add(bottomBeam.mRightBottomPoint); Comparison <Point> sorterX = new Comparison <Point>(CDimTools.ComparePointX); downDimPointList.Sort(sorterX); PointList pointList = new PointList(); foreach (Point point in downDimPointList) { pointList.Add(point); } double dimDistance = Math.Abs(CCommonPara.mViewMinY - downDimPointList[0].Y) + 1.5 * CCommonPara.mDefaultDimDistance; Vector downDimVector = new Vector(0, -1, 0); CDimTools.GetInstance().DrawDimensionSet(mViewBase, pointList, downDimVector, dimDistance, CCommonPara.mSizeDimPath); }
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) { IsNeedStop = false; INeedStopCount = 0; MouseDownTime = DateTime.Now; IsIgnore = false; if (IsRun) { IsRun = false; _timer2.Stop(); } if (!IsDisplay) { IsDisplay = true; if (_scrollbar.Tag.ToString() != "1") { _scrollbar.Tag = "1"; } } IsTryFixedMomentum = false; PointList.Clear(); _currentPoint = FirstPoint = _previousPoint = _previousPreviousPoint = e.GetPosition(this); PointList.Add(_currentPoint); Momentum = new Vector(0, 0); BeginDrag(); if (_dragScrollTimer != null) { e.Handled = true; } }
public MeterPointListView() { this.pointList = new PointList(); InitializeComponent(); this.DataContext = this; this.pointList.Add(new MeterPoint() { BACnetDevice = "NAE-1", BACnetID = "123123", BACnetIP = "123.123.123.123", BACnetName = "whatever", LucidID = "wber_blah", LastPosted = new DateTime(), LastUpdated = new DateTime() }); this.pointList.Add(new MeterPoint() { BACnetDevice = "NAE-2", BACnetID = "123123", BACnetIP = "123.123.123.123", BACnetName = "whatever", LucidID = "wber_blah", LastPosted = new DateTime(), LastUpdated = new DateTime() }); this.pointList.Add(new MeterPoint() { BACnetDevice = "NAE-3", BACnetID = "123123", BACnetIP = "123.123.123.123", BACnetName = "whatever", LucidID = "wber_blah", LastPosted = new DateTime(), LastUpdated = new DateTime() }); this.pointList.Add(new MeterPoint() { BACnetDevice = "NAE-4", BACnetID = "123123", BACnetIP = "123.123.123.123", BACnetName = "whatever", LucidID = "wber_blah", LastPosted = new DateTime(), LastUpdated = new DateTime() }); }
/// <summary> /// マス情報をダウンロードし、リストに登録する /// </summary> private async Task RefreshPointList() { // 入力バリデーション if (MapSelectIndex.Value < 0 || MapList.Count <= MapSelectIndex.Value || LevelSelectIndex.Value < 0 || LevelList.Count <= LevelSelectIndex.Value) { return; } // ダウンロード開始 PointList.Clear(); var list = await model.GetPointList(MapList[MapSelectIndex.Value], LevelList[LevelSelectIndex.Value]); if (list.Count == 0) { MessageBox.Show("マス情報をダウンロードできませんでした。", "AWSK", MessageBoxButton.OK, MessageBoxImage.Error); return; } foreach (string pointName in list) { PointList.Add(pointName); } }
/// <summary> /// Saves a <see cref="PointList"/>'s <see cref="RawPoint"/> to a file. /// </summary> /// <param name="pointList">The PointList so save.</param> /// <param name="filePath">The complete path to the file. You can use <see cref="FolderPath"/> to get the default RawPoint folder.</param> public static void Save(PointList pointList, string filePath) { try { var culture = CultureInfo.GetCultureInfo("en-US"); var data = pointList.RawPoints; using (var writer = new StreamWriter(File.Create(filePath))) { foreach (var point in data) { var pos = point.Position.RoundVector3(); var rot = point.Rotation.RoundVector3(); writer.WriteLine( $"{point.Id}:{point.RoomType}:{pos.x.ToString(culture)},{pos.y.ToString(culture)},{pos.z.ToString(culture)}:{rot.x.ToString(culture)},{rot.y.ToString(culture)},{rot.z.ToString(culture)}"); } } } catch (Exception e) { Log.Error($"Could not save Raw Point data: {e.Message}"); } }
public override List <InputDefinition> DefineInput() { List <InputDefinition> inputs = new List <InputDefinition>(); DrawingHandler drawingHandler = new DrawingHandler(); if (drawingHandler.GetConnectionStatus()) { Picker picker = drawingHandler.GetPicker(); ViewBase view = null; PointList points = new PointList(); StringList prompts = new StringList(); prompts.Add("Pick first point"); prompts.Add("Pick second point"); picker.PickPoints(2, prompts, out points, out view); inputs.Add(InputDefinitionFactory.CreateInputDefinition(view, points)); } return(inputs); }
/** * Generates a maze using a randomized version of Prim's algorithm. * * @returns a IEnumerable of passages */ //For some reason, the generic version gives a TypeLoadException in Unity (but not when run from visual studio). /* * public static IEnumerable<TEdge> GenerateMazeWalls<TGrid, TPoint, TEdge>(TGrid grid) * where TEdge : IGridPoint<TEdge>, IEdge<TPoint> * where TPoint : IGridPoint<TPoint>, ISupportsEdges<TEdge> * where TGrid : ISupportsEdgeGrid<TEdge>, IGridSpace<TPoint> * { * IGrid<bool, TEdge> walls = grid.MakeEdgeGrid<bool>(); //true indicates passable * var wallList = new List<TEdge>(); * * TPoint newMaizePoint = grid.RandomItem<TPoint>(); * var inMaze = new List<TPoint>(); * inMaze.Add(newMaizePoint); * * var edges = newMaizePoint.GetEdges(); * wallList.AddRange(edges); * * while (wallList.Any()) * { * var randomWall = wallList.RandomItem(); * IEnumerable<TPoint> faces = (randomWall as IEdge<TPoint>).GetEdgeFaces().Where(x => grid.Contains(x)); * * //At least one of the two faces must be in the maze * if (faces.Any(point => !inMaze.Contains(point))) * { * newMaizePoint = faces.First(point => !inMaze.Contains(point)); * inMaze.Add(newMaizePoint); * walls[randomWall] = true; * * yield return randomWall; * * // Add all edges that are not passages * edges = newMaizePoint.GetEdges().Where(edge => !(walls[edge])); * wallList.AddRange(edges); * } * else * { * wallList.Remove(randomWall); * } * } * yield return (TEdge)(object) g.First(); * yield break; * } */ /** * Generates a maze using a randomized version of Prim's algorithm. * * @returns a IEnumerable of passages */ public static IEnumerable <PointyRhombPoint> GenerateMazeWalls <TCell>(FlatTriGrid <TCell> grid) { var walls = grid.MakeEdgeGrid <bool>(); //true indicates passable var wallList = new PointList <PointyRhombPoint>(); var newMaizePoint = grid.RandomItem(); var inMaze = new PointList <FlatTriPoint> { newMaizePoint }; var edges = newMaizePoint.GetEdges(); wallList.AddRange(edges); while (wallList.Any()) { var randomWall = wallList.RandomItem(); var faces = (randomWall as IEdge <FlatTriPoint>).GetEdgeFaces().Where(x => grid.Contains(x)); //At least one of the two faces must be in the maze if (faces.Any(point => !inMaze.Contains(point))) { newMaizePoint = faces.First(point => !inMaze.Contains(point)); inMaze.Add(newMaizePoint); walls[randomWall] = true; yield return(randomWall); // Add all edges that are not passages edges = newMaizePoint.GetEdges().Where(edge => !(walls[edge])); wallList.AddRange(edges); } else { wallList.Remove(randomWall); } } }
///<summary> ///построить строку заголовка ///</summary> private TableRow BuildHeaderRow() { var tr = new TableRow(); var td = new TableCell() { Text = @"Инстанции <br /> \ <br /> Документы", HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center, CssClass = "headerCell" }; tr.Cells.Add(td); var list = PointList.OrderBy(x => x.position); for (int i = 0; i < PointList.Count; i++) { td = new TableCell() { CssClass = "headerCell" }; var l = new Literal() { Text = string.Format("{0};<br />{1}", list.ElementAt(i).state, list.ElementAt(i).divisionName) }; td.Controls.Add(l); tr.Cells.Add(td); } var endCell = new TableCell() { CssClass = "endCell" }; tr.Cells.Add(endCell); return(tr); }
/// <summary> /// 更新顶点列表 /// </summary> protected void UpdateTrackVertexList() { if (State == DrawState.Drawing && !movingPt.IsNaN) { if (movingFill) { Point3d[] Pts = new Point3d[PointList.Count + 1]; PointList.CopyTo(Pts); Pts[PointList.Count] = movingPt; CreatePolygon(Pts); } else { List <CustomVertex.PositionColored> movingPcs1 = getCurveFromPoints(PointList[PointList.Count - 1], movingPt, lineColor); List <CustomVertex.PositionColored> movingPcs2 = getCurveFromPoints(movingPt, PointList[0], lineColor); pcs = null; pcs = new CustomVertex.PositionColored[VertexList.Count + movingPcs1.Count + movingPcs2.Count - 2]; VertexList.CopyTo(pcs); movingPcs1.CopyTo(1, pcs, VertexList.Count, movingPcs1.Count - 1); movingPcs2.CopyTo(1, pcs, VertexList.Count + movingPcs1.Count - 1, movingPcs2.Count - 1); } } }
private void Board_OnMouseDown(object sender, MouseButtonEventArgs e) { var position = e.GetPosition(this); DrawEllipse(position); PointList.Add(position); var polygon = new Polygon() { Points = new PointCollection(PointList), Stroke = Brushes.Red, }; AddElement(nameof(polygon), polygon); if (e.RightButton == MouseButtonState.Pressed) { CleanBoard(); PointList.Clear(); } }
private void UpdatePoints(IList <Point> oldList) { foreach (Point point in PointList) { if (oldList.Contains(point)) { continue; } AddPoint(point); } if (oldList == null) { return; } foreach (Point point in oldList) { if (PointList.Contains(point)) { continue; } RemovePoint(point); } }
public List<AbstractTileAction> GetActionsAtObserverLocation(Avatar observer) { MapTile observerTile = _quest.GetAvatarMapTile(observer); Point observerLocation = _quest.Map.GetMapTileLocation(observerTile); //// Get a list of all actionable map tiles PointList interestingLocations = _quest.Map.GetActionableMapPoints(observer.Faction); // Filter out interesting locations that are not in the visible set PointList observerLocations = new PointList(); observerLocations.Add(observerLocation); PointList visibleInterestingLocations = interestingLocations.Intersects(observerLocations); List<AbstractTileAction> actions = new List<AbstractTileAction>(); for (int i = 0; i < visibleInterestingLocations.Count; i++) { List<AbstractTileAction> actionsAtInterestingLocation = _quest.Map.GetActionsForPoint(observerLocation); foreach (AbstractTileAction actionAtInterestingLocation in actionsAtInterestingLocation) { actions.Add(actionAtInterestingLocation); } } return actions; }
// Update is called once per frame void OnDrawGizmos() { if(points == null || points.Count < 1){ return; } // ShapePath pointList = new PointList(); // ShapePath if (pointList != null) { shapePath = pointList.GetShapePath(points.ToArray(), rots.ToArray()); for (int i = 0; i < num; i++) { float v = (float)i / num; Vector3 pt; // pt = shapePath.getPointInfoVec3Percent(v); PathVector pv = shapePath.getPathInfo(v); pt = new Vector3(pv.x, pv.y, pv.z); Gizmos.color = color; Gizmos.DrawWireSphere(pt, 0.25f); Quaternion rot = pv.rot; // Gizmos.color = new Color(0, 0, 0, 0.25f); Gizmos.DrawRay(pt, rot * Vector3.up * 2); Gizmos.DrawRay(pt, rot * Vector3.right * 2); Quaternion q2 = GetQuaternionAt(v); Gizmos.color = Color.green; Gizmos.DrawRay (pt, q2* Vector3.up); Gizmos.color = Color.red; Gizmos.DrawRay (pt, q2* Vector3.right); } } }
private bool Snip(PointList contour, int u, int v, int w, int n, int[] V) { int p; float Ax, Ay, Bx, By, Cx, Cy, Px, Py; Ax = contour.Get(V[u]).GetX(); Ay = contour.Get(V[u]).GetY(); Bx = contour.Get(V[v]).GetX(); By = contour.Get(V[v]).GetY(); Cx = contour.Get(V[w]).GetX(); Cy = contour.Get(V[w]).GetY(); if (EPSILON > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax)))) { return(false); } for (p = 0; p < n; p++) { if ((p == u) || (p == v) || (p == w)) { continue; } Px = contour.Get(V[p]).GetX(); Py = contour.Get(V[p]).GetY(); if (InsideTriangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py)) { return(false); } } return(true); }
/// <summary> /// 绘制支撑板及牛腿上的螺钉在Y方向的标注; /// </summary> private void DrawSupportPlateBoltDimY() { CCylinderTopViewSetting cylinderTopViewSetting = CCylinderDimSetting.GetInstance().mTopViewSetting; if (!cylinderTopViewSetting.FindDimValueByName(CCylinderTopViewSetting.mstrSupportPlate)) { return; } //移除主梁; mMrPartList.Remove(mMainBeam); foreach (CMrPart mrPart in mMrPartList) { CMrDimSet mrDimSet = mrPart.GetCylinderTopViewInfo().GetSupportPlateBoltYDimSet(); if (mrDimSet == null || mrDimSet.Count <= 1) { continue; } List <Point> dimPointList = mrDimSet.GetDimPointList(); PointList pointList = new PointList(); foreach (Point point in dimPointList) { pointList.Add(point); } double dimDistance = mrDimSet.mDimDistance; Vector dimVector = mrDimSet.mDimVector; CDimTools.GetInstance().DrawDimensionSet(mViewBase, pointList, dimVector, dimDistance, CCommonPara.mSizeDimPath); } mMrPartList.Add(mMainBeam); }
private Vector PreviousVelocity(bool IsDistinct) { List <Point> pointList = null; if (IsDistinct) { pointList = PointList.Skip(Math.Max(0, PointList.Count() - 10)).Distinct().ToList(); } else { pointList = PointList.Skip(Math.Max(0, PointList.Count() - 10)).ToList(); } if (pointList.Count >= 1) { _previousPoint = pointList.ElementAtOrDefault(pointList.Count() - 1); } if (pointList.Count >= 2) { _previousPreviousPoint = pointList.ElementAtOrDefault(pointList.Count() - 2); } return(new Vector(_previousPoint.X - _previousPreviousPoint.X, _previousPoint.Y - _previousPreviousPoint.Y)); }
/// <summary> /// 绘制主梁左侧Y方向上的标注; /// </summary> private void DrawYMainLeftDim() { List <Point> leftDimPointList = new List <Point>(); foreach (CMrPart mrPart in mMrPartList) { CMrDimSet partDimSet = mrPart.GetCylinderDoorFrontViewInfo().GetYPartMainLeftDimSet(); if (partDimSet != null && partDimSet.Count > 0) { leftDimPointList.AddRange(partDimSet.GetDimPointList()); } } //1.得到顶部需要进行标注的零部件; CMrDimSet mrTopPartDimSet = GetTopPartDimSet(1); leftDimPointList.AddRange(mrTopPartDimSet.GetDimPointList()); Comparison <Point> sorterY = new Comparison <Point>(CDimTools.ComparePointY); leftDimPointList.Sort(sorterY); PointList pointList = new PointList(); foreach (Point point in leftDimPointList) { pointList.Add(point); } Point MinXPoint = leftDimPointList[0]; double dimDistance = Math.Abs(CCommonPara.mViewMinX - MinXPoint.X) + 2 * CCommonPara.mDefaultDimDistance; Vector rightDimVector = new Vector(-1, 0, 0); CDimTools.GetInstance().DrawDimensionSet(mViewBase, pointList, rightDimVector, dimDistance, CCommonPara.mSizeDimPath); }
//TODO make another option to use octrees void GenerateGrid() { Vector3 scale = _rootMesh.transform.localScale; foreach (var meshBoxCollider in _meshBoxColliderArr) { Vector3 boxColliderSize = meshBoxCollider.size; Vector3 worldSize = Vector3.Scale(meshBoxCollider.size, scale); Vector3 offset = Vector3.Scale(meshBoxCollider.center, scale) - worldSize * .5f; Vector3 cellsPerSide = new Vector3(worldSize.x / _gridCellSize.x, worldSize.y / _gridCellSize.y, worldSize.z / _gridCellSize.z); Vector3 halfCellSize = _gridCellSize * .5f; for (int x = 0; x <= (int)cellsPerSide.x; x++) { for (int y = 0; y <= (int)cellsPerSide.y; y++) { for (int z = 0; z <= (int)cellsPerSide.z; z++) { Vector3 pos = halfCellSize + (new Vector3(x * _gridCellSize.x, y * _gridCellSize.y, z * _gridCellSize.z)); pos += offset; if (IsInsideTest(pos, Vector3.forward)) { PointList.Add(pos); } } } } } if (_multiDirectionalCheck) { ReverseCollisionCheck(); } }
private void ParsePoints(XmlReader r) { r.ReadStartElement(); while (r.NodeType == XmlNodeType.Element) { if (r.Name == "Point") { Points.Add(new GenericPosturePoint(r)); } else { string outerXml = r.ReadOuterXml(); log.DebugFormat("Unparsed content in XML: {0}", outerXml); } } r.ReadEndElement(); foreach (var point in Points) { PointList.Add(point.Value); } }
private void ParseInitialConfiguration(XmlReader r) { r.ReadStartElement(); while (r.NodeType == XmlNodeType.Element) { if (r.Name == "Point") { PointF value = XmlHelper.ParsePointF(r.ReadElementContentAsString()); Points.Add(new GenericPosturePoint(value)); } else { string outerXml = r.ReadOuterXml(); log.DebugFormat("Unparsed content: {0}", outerXml); } } r.ReadEndElement(); foreach (var point in Points) { PointList.Add(point.Value); } }
public static PointList RadialScan(PointList inputList) { PointList result = new PointList(inputList); Point origin = result[(new Random()).Next(result.Count)]; result.Sort((p, q) => Point.Distance(origin, p).CompareTo(Point.Distance(origin, q))); result.Add(result[0]); return result; }
public override Value Evaluate(FSharpList<Value> args) { PointList points = new PointList(); var input = (args[0] as Value.List).Item; foreach (Value v in input) { Point p = ((Value.Container)v).Item as Point; points.Add(p); } _polygon = Polygon.by_vertices(points); return Value.NewContainer(_polygon); }
public static PointList RandomPath(PointList inputList) { PointList pointsLeft = new PointList(inputList); PointList result = new PointList(); Random rnd = new Random(); while (pointsLeft.Count > 0) { Point p = pointsLeft[rnd.Next(pointsLeft.Count)]; result.Add(p); pointsLeft.Remove(p); } result.Add(result[0]); return result; }
private void StopGettingData() { try { if (m_publishTimer != null) { m_publishTimer.Elapsed -= m_publishTimer_Tick; m_publishTimer.Stop(); m_publishTimer.Dispose(); } m_publishTimer = null; if (m_dataThread != null) m_dataThread.Abort(); m_dataThread = null; m_points = null; } catch (ThreadAbortException) { throw; } catch (Exception ex) { OnProcessException(ex); } }
private PointList<int, int> CalcEnemyShipCountPerSector() { PointList<int, int> result = new PointList<int, int>(); foreach (IVisible unit in mComputerView) if (unit is ISpaceship && unit.Allegiance == Allegiance.Player) { Point sector = mUnitSectorManager.GetSector(unit.Position); if (result.Contains(sector.X, sector.Y)) result.Set(sector.X, sector.Y, result.Get(sector.X, sector.Y)+1); else result.Add(sector.X, sector.Y, 1); } return result; }
private static IEnumerable<PairOfPoints> forEachPair(PointList points) { for (int i = 0; i < points.Count - 1; i++) for (int j = i + 1; j < points.Count; j++) yield return new PairOfPoints(points[i], points[j]); }
private static PointList incrementalInsertion(PointList inputList, Point startingPoint) { PointList pointsLeft = new PointList(inputList); pointsLeft.Remove(startingPoint); Point secondPoint = pointsLeft.OrderByDescending(point => Point.Distance(startingPoint, point)).ToList()[0]; PointList path = new PointList() { startingPoint, secondPoint, startingPoint }; pointsLeft.Remove(secondPoint); while (pointsLeft.Count > 0) { decimal maxDist = 0; int finalInsertionIndex = 0; Point farthestPoint = null; foreach (Point point in pointsLeft) { decimal minDist = decimal.MaxValue; int insertionIndex = 1; for (int i = 0; i < path.Count - 1; i++) { decimal dist = Point.Distance(path[i], point) + Point.Distance(point, path[i + 1]); if (dist < minDist) { minDist = dist; insertionIndex = i + 1; } } if (minDist > maxDist) { maxDist = minDist; finalInsertionIndex = insertionIndex; farthestPoint = point; } } path.Insert(finalInsertionIndex, farthestPoint); pointsLeft.Remove(farthestPoint); } return path; }
private static PointList nearestNeighbor(PointList inputList, Point startingPoint) { Point last = startingPoint; PointList visited = new PointList() { last }; PointList unvisited = inputList.Clone(); unvisited.Remove(last); while (unvisited.Count > 0) { Point next = findClosestPair(unvisited.ConvertAll(p => new PairOfPoints(last, p))).B; visited.Add(next); unvisited.Remove(next); last = next; } visited.Add(visited[0]); return visited; }
public static PointList Scan(PointList inputList) { PointList result = new PointList(inputList); result.Sort((p, q) => p.Y.CompareTo(q.Y) != 0 ? p.Y.CompareTo(q.Y) : p.X.CompareTo(q.X)); result.Add(result[0]); return result; }
public DrawPolygon() : base() { pointArray = new PointList(); Initialize(); }
private void StartGettingData(object state) { try { m_points = m_server.GetPoints(m_tagFilter); m_dataThread = new Thread(QueryData); m_dataThread.IsBackground = true; m_dataThread.Start(); m_publishTimer = new System.Timers.Timer(); m_publishTimer.Interval = ProcessingInterval; m_publishTimer.Elapsed += m_publishTimer_Tick; m_publishTimer.Start(); } catch (ThreadAbortException) { throw; } catch (Exception e) { OnProcessException(e); } }
public static PointList RoughScan(PointList inputList) { int rowCount = (int)Math.Round(Math.Sqrt(inputList.Count) / 2f) * 2; decimal lowestY = inputList.Min(p => p.Y); decimal highestY = inputList.Max(p => p.Y); decimal rowHeight = (highestY - lowestY) / rowCount; List<int> rowIndices = new List<int>(); for (int i = 0; i < rowCount; i++) rowIndices.Add(i); List<List<Point>> rows = rowIndices.ConvertAll(rowIndex => inputList.FindAll(point => point.Y >= (lowestY + rowHeight * rowIndex) && point.Y < (lowestY + rowHeight * (rowIndex + 1)))); rows[rows.Count - 1].AddRange(inputList.FindAll(point => point.Y == highestY)); rows = rows.Where(r => r.Count > 0).ToList(); PointList path = new PointList(); for (int i = 0; i < rows.Count; i++) { PointList rowPath = new PointList(rows[i].OrderBy(point => point.X * (decimal)Math.Pow(-1f, i))); rowPath = nearestNeighbor(rowPath, rowPath[0]); rowPath.RemoveAt(rowPath.Count - 1); path.AddRange(rowPath); } path.Add(path[0]); return path; }
/// <summary>Calculates all temporary lists.</summary> private void CalculateData() { GameLogic gameLogic = GameLogic.GetInstance(); mComputerView = gameLogic.mComputerView; mUnitSectorManager = gameLogic.SectorManager; mComputerPlayerRelations = new PointList<int, float>(); mSurroundingPlayerDs = new PointList<int, int>(); mEnemyPlanetDefenses = CalcVisibleEnemyPlanetsWithSpaceships(); mPlanetDefenseUrgencies = CalcPlanetDefenseUrgencies(); mEnemyShipCountPerSector = CalcEnemyShipCountPerSector(); mEnemyPlanetBlockUrgencies = CalcEnemyPlanetBlockUrgencies(); mCrusadeFeasibilities = CalcCrusadeFeasibilities(); mAngleToEnemy = CalcEnemyAngles(); }