code: func (p *Path) DirectionAt(index int) float64 {
  	if index >= len(p.PointSet) || index < 0 {
  		panic(fmt.Sprintf("geo: direction at index out of range, requested: %d, length: %d", index, len(p.PointSet)))
  	}
  
  	if len(p.PointSet) == 1 {
  		return math.Inf(1)
  	}
  
  	var diff *Point
  	if index == 0 {
  		diff = p.GetAt(1).Clone().Subtract(p.GetAt(0))
  	} else if index >= p.Length()-1 {
  		length := p.Length()
  		diff = p.GetAt(length - 1).Clone().Subtract(p.GetAt(length - 2))
  	} else {
  		diff = p.GetAt(index + 1).Clone().Subtract(p.GetAt(index - 1))
  	}
  
  	return math.Atan2(diff.Y(), diff.X())
  }
docs: // DirectionAt computes the direction of the path at the given index.
  // Uses the line between the two surrounding points to get the direction,
  // or just the first two, or last two if at the start or end, respectively.
  // Assumes the path is in a conformal projection.
  // The units are radians from the positive x-axis. Range same as math.Atan2, [-Pi, Pi]
  // Returns INF for single point paths.