Skip to content

Commit

Permalink
add angle 3D builder
Browse files Browse the repository at this point in the history
  • Loading branch information
berberman committed Nov 15, 2019
1 parent e4bd722 commit 7d9f3fe
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/main/kotlin/org/mechdancer/geometry/rotation3d/Angle3D.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
33 changes: 33 additions & 0 deletions src/main/kotlin/org/mechdancer/geometry/rotation3d/Builder.kt
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit 7d9f3fe

Please sign in to comment.