mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
This uses std::is_constant_evaluated() to conditionally use the gcem library for constexpr calculations.
22 lines
600 B
C++
22 lines
600 B
C++
// Copyright (c) FIRST and other WPILib contributors.
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
#include "frc/geometry/Rotation2d.h"
|
|
|
|
#include <cmath>
|
|
|
|
#include <wpi/json.h>
|
|
|
|
#include "units/math.h"
|
|
|
|
using namespace frc;
|
|
|
|
void frc::to_json(wpi::json& json, const Rotation2d& rotation) {
|
|
json = wpi::json{{"radians", rotation.Radians().value()}};
|
|
}
|
|
|
|
void frc::from_json(const wpi::json& json, Rotation2d& rotation) {
|
|
rotation = Rotation2d{units::radian_t{json.at("radians").get<double>()}};
|
|
}
|