src/map.cpp
// Transform from Frenet s,d coordinates to Cartesian x,y
Transform from Frenet s,d coordinates to Cartesian x,y
Transform from Frenet s d coordinates to Cartesian x y
vector<double> Map::getXY(double s, double d) {
  int prev_wp = -1;
  while (s > high_res_map_waypoints_s_[prev_wp + 1] &&
         (prev_wp < (int)(high_res_map_waypoints_s_.size() - 1))) {
    prev_wp++;
  }
  int wp2 = (prev_wp + 1) % high_res_map_waypoints_x_.size();
  double heading = atan2(
      (high_res_map_waypoints_y_[wp2] - high_res_map_waypoints_y_[prev_wp]),
      (high_res_map_waypoints_x_[wp2] - high_res_map_waypoints_x_[prev_wp]));
  double seg_s = (s - high_res_map_waypoints_s_[prev_wp]);
  double seg_x = high_res_map_waypoints_x_[prev_wp] + seg_s * cos(heading);
  double seg_y = high_res_map_waypoints_y_[prev_wp] + seg_s * sin(heading);
  double perp_heading = heading - M_PI / 2;
  double x = seg_x + d * cos(perp_heading);
  double y = seg_y + d * sin(perp_heading);
  return {x, y};
}
vector < double > Map :: getXY ( double s , double d ) { int prev_wp = -1 ; while ( s > high_res_map_waypoints_s_ [ prev_wp + 1 ] && ( prev_wp < ( int ) ( high_res_map_waypoints_s_ . size ( ) - 1 ) ) ) { prev_wp ++ ; } int wp2 = ( prev_wp + 1 ) % high_res_map_waypoints_x_ . size ( ) ; double heading = atan2 ( ( high_res_map_waypoints_y_ [ wp2 ] - high_res_map_waypoints_y_ [ prev_wp ] ) , ( high_res_map_waypoints_x_ [ wp2 ] - high_res_map_waypoints_x_ [ prev_wp ] ) ) ; double seg_s = ( s - high_res_map_waypoints_s_ [ prev_wp ] ) ; double seg_x = high_res_map_waypoints_x_ [ prev_wp ] + seg_s * cos ( heading ) ; double seg_y = high_res_map_waypoints_y_ [ prev_wp ] + seg_s * sin ( heading ) ; double perp_heading = heading - M_PI / 2 ; double x = seg_x + d * cos ( perp_heading ) ; double y = seg_y + d * sin ( perp_heading ) ; return { x , y } ; }
Transform from Frenet s,d coordinates to Cartesian x,y
Transform from Frenet s d coordinates to Cartesian x y