/// <summary> /// 编写自己的构造函数 /// </summary> /// <param name="startPara">起始点</param> /// <param name="pointNumPara">当前点坐标</param> /// <param name="goalPara">目标点坐标</param> /// <param name="m_Input">输入场景信息</param> /// <param name="mParentNode">父节点</param> public Node(FPoint3 startPara, FPoint3 pointNumPara, FPoint3 goalPara, Node mParentNode) : base() { NodeLocation = pointNumPara; ParentNode = mParentNode; CostfromStart = mParentNode.CostfromStart + FPoint2.DistanceBetweenTwoPlanePoints(NodeLocation, mParentNode.NodeLocation); //DistancetoGoal = FPoint3.DistanceBetweenTwoSpacePointsXY(NodeLocation, goalPara); DistancetoGoal = FPoint2.DistanceBetweenTwoPlanePoints(NodeLocation, goalPara); computeCostForAStar = CostfromStart + DistancetoGoal; }
/// <summary> /// 构造函数 - 专为初始节点设置的构造函数 /// </summary> /// <param name="mFPoint3">点</param> /// <param name="flightDirection">飞行方向(</param> /// <param name="mParentNode">父节点</param> public Node(FPoint3 mFPoint3, FPoint3 goalPara, double costfromStart, Node mParentNode) : base() { //将参数传入节点内进行初始化 NodeLocation = new FPoint3(mFPoint3.X, mFPoint3.Y, mFPoint3.Z); ParentNode = mParentNode; CostfromStart = costfromStart; //DistancetoGoal = Math.Min(Math.Abs(NodeLocation.X - goalPara.X), (NodeLocation.Y - goalPara.Y)) * (Math.Sqrt(2) - 1) // + Math.Max(Math.Abs(NodeLocation.X - goalPara.X), (NodeLocation.Y - goalPara.Y)); DistancetoGoal = FPoint2.DistanceBetweenTwoPlanePoints(NodeLocation, goalPara); }