/*public Graph2dNode this[IVector2 _coord] * { * get { return m_Nodes[_coord]; } * }*/ public double GetEdgeWeight(IVector2 _from, G2Dir _direction) { if (Bidirectional) { return(m_Nodes[_from].GetEdge(_direction)); } else { return(m_Nodes[_from + DirMap.Get(_direction)].Weight); } }
/// <summary> /// Bidirectional use only. Returns edge weight in specified direction. /// </summary> /// <param name="_direction"></param> /// <returns></returns> internal double GetEdge(G2Dir _direction) { if (!bidirectional) { throw new NotImplementedException(); } if ((int)_direction < 0 || (int)_direction > 7) { throw new ArgumentException(); } return(m_EdgeWeight[(int)_direction]); }
/// <summary> /// Bidirectional use only. Creates and returns an exact copy with the new weight at specified edge in specified direction. /// </summary> /// <param name="_direction"></param> /// <param name="_weight"></param> /// <returns></returns> internal Graph2dNode CreateUpdatedEdge(G2Dir _direction, double _weight) { if (bidirectional) { if (m_EdgeWeight[(int)_direction] == _weight) { return(this); } var newWeights = new double[8]; for (int i = 0; i < 8; ++i) { if (i == (int)_direction) { newWeights[i] = _weight; } else { newWeights[i] = m_EdgeWeight[i]; } } return(new Graph2dNode(newWeights)); } throw new NotImplementedException(); }
public static IVector2 Get(G2Dir _dir) { return(Vecs[(int)_dir]); }