exc/udemy-cpp/exc01/AdFunctions.cc

48 lines
820 B
C++
Raw Normal View History

#include <cmath>
#include <cstdint>
#include <iostream>
#include "AdConstants.h"
#include "AdFunctions.h"
2023-07-13 18:59:42 +02:00
namespace Ad
{
namespace Utils
{
constexpr float kph_to_mps(const float kph)
{
return 0.2778 * kph;
}
} // namespace Ad::Utils
namespace Data
{
Types::Vehicle init_ego_vehicle()
{
return Types::Vehicle{
.id = Constants::EGO_VEHICLE_ID,
.lane = Types::Lane::Center,
.speed_mps = Utils::kph_to_mps(135),
.rel_distance_m = 0,
2023-07-13 18:59:42 +02:00
};
}
} // namespace Ad::Data
namespace Visualize
{
2023-07-13 18:59:42 +02:00
void print_vehicle(const Types::Vehicle vehicle)
{
std::cout << "Vehicle " << vehicle.id << '\n';
std::cout << "speed : " << vehicle.speed_mps << " m/s\n";
std::cout << "distance : " << vehicle.rel_distance_m << " m\n";
}
} // namespace Ad::Visualize
} // namespace Ad