Files
allwpilib/wpimath/src/main/native/cpp/geometry/Rotation2d.cpp

16 lines
589 B
C++
Raw Normal View History

// 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.
2025-11-07 19:56:21 -05:00
#include "wpi/math/geometry/Rotation2d.hpp"
2025-11-07 19:56:21 -05:00
#include "wpi/util/json.hpp"
2025-11-07 20:00:05 -05:00
void wpi::math::to_json(wpi::util::json& json, const Rotation2d& rotation) {
2026-03-29 15:38:18 -07:00
json = wpi::util::json::object("radians", rotation.Radians().value());
}
2025-11-07 20:00:05 -05:00
void wpi::math::from_json(const wpi::util::json& json, Rotation2d& rotation) {
2026-03-29 15:38:18 -07:00
rotation = Rotation2d{wpi::units::radian_t{json.at("radians").get_number()}};
}