2025-08-30 11:37:09 -07:00
|
|
|
// 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 <jni.h>
|
|
|
|
|
|
|
|
|
|
#include <wpi/jni_util.h>
|
|
|
|
|
|
2025-11-07 19:55:43 -05:00
|
|
|
#include "org_wpilib_math_jni_Transform3dJNI.h"
|
2025-08-30 11:37:09 -07:00
|
|
|
#include "frc/geometry/Quaternion.h"
|
|
|
|
|
#include "frc/geometry/Rotation3d.h"
|
|
|
|
|
#include "frc/geometry/Transform3d.h"
|
|
|
|
|
#include "frc/geometry/Twist3d.h"
|
|
|
|
|
#include "units/angle.h"
|
|
|
|
|
#include "units/length.h"
|
|
|
|
|
|
|
|
|
|
using namespace wpi::java;
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
|
|
/*
|
2025-11-07 19:55:43 -05:00
|
|
|
* Class: org_wpilib_math_jni_Transform3dJNI
|
2025-08-30 11:37:09 -07:00
|
|
|
* Method: log
|
|
|
|
|
* Signature: (DDDDDDD)[D
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jdoubleArray JNICALL
|
2025-11-07 19:55:43 -05:00
|
|
|
Java_org_wpilib_math_jni_Transform3dJNI_log
|
2025-08-30 11:37:09 -07:00
|
|
|
(JNIEnv* env, jclass, jdouble relX, jdouble relY, jdouble relZ, jdouble relQw,
|
|
|
|
|
jdouble relQx, jdouble relQy, jdouble relQz)
|
|
|
|
|
{
|
|
|
|
|
frc::Transform3d transform3d{
|
|
|
|
|
units::meter_t{relX}, units::meter_t{relY}, units::meter_t{relZ},
|
|
|
|
|
frc::Rotation3d{frc::Quaternion{relQw, relQx, relQy, relQz}}};
|
|
|
|
|
|
|
|
|
|
frc::Twist3d result = transform3d.Log();
|
|
|
|
|
|
|
|
|
|
return MakeJDoubleArray(
|
|
|
|
|
env, {{result.dx.value(), result.dy.value(), result.dz.value(),
|
|
|
|
|
result.rx.value(), result.ry.value(), result.rz.value()}});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // extern "C"
|