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

22 lines
911 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/Translation3d.hpp"
2025-11-07 19:56:21 -05:00
#include "wpi/util/json.hpp"
2025-11-07 20:01:58 -05:00
void wpi::math::to_json(wpi::util::json& json,
const Translation3d& translation) {
2025-11-07 20:00:05 -05:00
json = wpi::util::json{{"x", translation.X().value()},
2025-11-07 20:01:58 -05:00
{"y", translation.Y().value()},
{"z", translation.Z().value()}};
}
2025-11-07 20:01:58 -05:00
void wpi::math::from_json(const wpi::util::json& json,
Translation3d& translation) {
2025-11-07 20:00:05 -05:00
translation = Translation3d{wpi::units::meter_t{json.at("x").get<double>()},
wpi::units::meter_t{json.at("y").get<double>()},
wpi::units::meter_t{json.at("z").get<double>()}};
}