diff --git a/src/main/kotlin/org/mechdancer/geometry/rotation3d/Angle3D.kt b/src/main/kotlin/org/mechdancer/geometry/rotation3d/Angle3D.kt index 5925ec2..054912f 100644 --- a/src/main/kotlin/org/mechdancer/geometry/rotation3d/Angle3D.kt +++ b/src/main/kotlin/org/mechdancer/geometry/rotation3d/Angle3D.kt @@ -36,13 +36,6 @@ data class Angle3D(val first: Angle, val second: Angle, val third: Angle, val ax } } - /** - * 转为内旋 - * - * Intrinsic - */ - fun toEuler() = copy(axesOrder = axesOrder.reverse()) - companion object { /** * 绕 X 轴逆时针旋转 [angle] diff --git a/src/main/kotlin/org/mechdancer/geometry/rotation3d/Builder.kt b/src/main/kotlin/org/mechdancer/geometry/rotation3d/Builder.kt new file mode 100644 index 0000000..7df71c8 --- /dev/null +++ b/src/main/kotlin/org/mechdancer/geometry/rotation3d/Builder.kt @@ -0,0 +1,33 @@ +package org.mechdancer.geometry.rotation3d + +import org.mechdancer.algebra.core.Matrix +import org.mechdancer.geometry.angle.Angle + +/** + * 构造内旋 [Angle3D] + */ +fun euler(first: Angle, second: Angle, third: Angle, axesOrder: AxesOrder = AxesOrder.ZYZ) = + Angle3D(first, second, third, axesOrder.reverse()) + +/** + * 构造外旋 [Angle3D] + */ +fun rollPitchYaw(first: Angle, second: Angle, third: Angle, axesOrder: AxesOrder = AxesOrder.XYZ) = + Angle3D(first, second, third, axesOrder) + +/** + * 从矩阵反解旋转角度 + * + * 请见 [Angle3D.fromMatrix] + */ +fun Matrix.toRollPitchYaw(axesOrder: AxesOrder) = + Angle3D.fromMatrix(this, axesOrder) + +/** + * 从矩阵反解旋转角度 + * + * 请见 [Angle3D.fromMatrix] + */ +fun Matrix.toEuler(axesOrder: AxesOrder) = + Angle3D.fromMatrix(this, axesOrder.reverse()) +