us.ihmc.robotics.geometry.GeometryTools.getAxisAngleFromFirstToSecondVector()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(58)

本文整理了Java中us.ihmc.robotics.geometry.GeometryTools.getAxisAngleFromFirstToSecondVector()方法的一些代码示例,展示了GeometryTools.getAxisAngleFromFirstToSecondVector()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeometryTools.getAxisAngleFromFirstToSecondVector()方法的具体详情如下:
包路径:us.ihmc.robotics.geometry.GeometryTools
类名称:GeometryTools
方法名:getAxisAngleFromFirstToSecondVector

GeometryTools.getAxisAngleFromFirstToSecondVector介绍

[英]Computes the complete minimum rotation from firstVector to the secondVector and packs it into an AxisAngle4d. The rotation axis if perpendicular to both vectors. The rotation angle is computed as the angle from the firstVector to the secondVector:
rotationAngle = firstVector.angle(secondVector).
Note: the vectors do not need to be unit length.

Edge cases:

  • the vectors are the same: the rotation angle is equal to 0.0 and the rotation axis is set to: (1, 0, 0).
  • the vectors are collinear pointing opposite directions: the rotation angle is equal to Math.PI and the rotation axis is set to: (1, 0, 0).
  • if the length of either normal is below 1.0E-7: the rotation angle is equal to 0.0 and the rotation axis is set to: (1, 0, 0).

Note: The calculation becomes less accurate as the two vectors are more collinear.
[中]计算从第一个向量到第二个向量的完整最小旋转,并将其打包为AxisAngle4d。如果垂直于两个矢量,则旋转轴。旋转角度计算为从第一个矢量到第二个矢量的角度:
旋转角度=第一个向量。角度(第二矢量)。
注:矢量不需要是单位长度。
边缘情况:
*矢量相同:旋转角度等于0.0,旋转轴设置为:(1,0,0)。
*向量是指向相反方向的共线:旋转角度等于数学。PI,旋转轴设置为:(1,0,0)。
*如果任一法线的长度低于1.0E-7:旋转角度等于0.0,旋转轴设置为:(1,0,0)。
注:由于两个向量更为共线,因此计算的精度降低。

代码示例

代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit

/**
* Computes the complete minimum rotation from {@code zUp = (0, 0, 1)} to the given {@code vector} and packs it into an {@link AxisAngle4d}.
* The rotation axis if perpendicular to both vectors.
* The rotation angle is computed as the angle from the {@code zUp} to the {@code vector}:
* <br> {@code rotationAngle = zUp.angle(vector)}. </br>
* Note: the vector does not need to be unit length.
* <p>
* Edge cases:
* <ul>
*    <li> the vector is aligned with {@code zUp}: the rotation angle is equal to {@code 0.0} and the rotation axis is set to: (1, 0, 0).
*    <li> the vector is collinear pointing opposite direction of {@code zUp}: the rotation angle is equal to {@code Math.PI} and the rotation axis is set to: (1, 0, 0).
*    <li> if the length of the given normal is below {@code 1.0E-7}: the rotation angle is equal to {@code 0.0} and the rotation axis is set to: (1, 0, 0).
* </ul>
* </p>
* <p>
* Note: The calculation becomes less accurate as the two vectors are more collinear.
* </p>
* 
* @param vector the vector that is rotated with respect to {@code zUp}. Not modified.
* @param rotationToPack the minimum rotation from {@code zUp} to the given {@code vector}. Modified.
*/
public static void getAxisAngleFromZUpToVector(Vector3d vector, AxisAngle4d rotationToPack)
{
 getAxisAngleFromFirstToSecondVector(0.0, 0.0, 1.0, vector.getX(), vector.getY(), vector.getZ(), rotationToPack);
}

代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit

/**
* Computes the complete minimum rotation from {@code firstVector} to the {@code secondVector} and packs it into an {@link AxisAngle4d}.
* The rotation axis if perpendicular to both vectors.
* The rotation angle is computed as the angle from the {@code firstVector} to the {@code secondVector}:
* <br> {@code rotationAngle = firstVector.angle(secondVector)}. </br>
* Note: the vectors do not need to be unit length.
* <p>
* Edge cases:
* <ul>
*    <li> the vectors are the same: the rotation angle is equal to {@code 0.0} and the rotation axis is set to: (1, 0, 0).
*    <li> the vectors are collinear pointing opposite directions: the rotation angle is equal to {@code Math.PI} and the rotation axis is set to: (1, 0, 0).
*    <li> if the length of either normal is below {@code 1.0E-7}: the rotation angle is equal to {@code 0.0} and the rotation axis is set to: (1, 0, 0).
* </ul>
* </p>
* <p>
* Note: The calculation becomes less accurate as the two vectors are more collinear.
* </p>
* 
* @param firstVector the first vector. Not modified.
* @param secondVector the second vector that is rotated with respect to the first vector. Not modified.
* @param rotationToPack the minimum rotation from {@code firstVector} to the {@code secondVector}. Modified.
*/
public static void getAxisAngleFromFirstToSecondVector(Vector3d firstVector, Vector3d secondVector, AxisAngle4d rotationToPack)
{
 getAxisAngleFromFirstToSecondVector(firstVector.getX(), firstVector.getY(), firstVector.getZ(), secondVector.getX(), secondVector.getY(),
                   secondVector.getZ(), rotationToPack);
}

代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit

alignAxisWithThis.changeFrame(currentXYZAxis.getReferenceFrame());
AxisAngle4d rotationToDesired = new AxisAngle4d();
GeometryTools.getAxisAngleFromFirstToSecondVector(currentXYZAxis.getVector(), alignAxisWithThis.getVector(), rotationToDesired);
alignAxisWithThis.changeFrame(initialFrame);

代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit

rayThroughSphere.normalize();
GeometryTools.getAxisAngleFromFirstToSecondVector(xAxis, rayThroughSphere, rotationForXAxisAlignedWithRay);
rotationMatrixForXAxisAlignedWithRay.set(rotationForXAxisAlignedWithRay);

代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit

public static ReferenceFrame constructReferenceFrameFromPointAndAxis(String frameName, FramePoint point, Axis axisToAlign, FrameVector alignAxisWithThis)
{
 point.checkReferenceFrameMatch(alignAxisWithThis.getReferenceFrame());
 FrameVector referenceNormal = new FrameVector();
 switch (axisToAlign)
 {
 case X:
   referenceNormal.setIncludingFrame(point.getReferenceFrame(), 1.0, 0.0, 0.0);
   break;
 case Y:
   referenceNormal.setIncludingFrame(point.getReferenceFrame(), 0.0, 1.0, 0.0);
   break;
 case Z:
   referenceNormal.setIncludingFrame(point.getReferenceFrame(), 0.0, 0.0, 1.0);
   break;
 default:
   break;
 }
 
 AxisAngle4d rotationToDesired = new AxisAngle4d();
 alignAxisWithThis.changeFrame(referenceNormal.getReferenceFrame());
 GeometryTools.getAxisAngleFromFirstToSecondVector(referenceNormal.getVectorCopy(), alignAxisWithThis.getVectorCopy(), rotationToDesired);
 
 RigidBodyTransform transformToDesired = new RigidBodyTransform();
 transformToDesired.setRotation(rotationToDesired);
 Vector3d translation = new Vector3d();
 point.get(translation);
 transformToDesired.setTranslation(translation);
 return constructFrameWithUnchangingTransformToParent(frameName, point.getReferenceFrame(), transformToDesired);
}

代码示例来源:origin: us.ihmc/IHMCHumanoidBehaviors

GeometryTools.getAxisAngleFromFirstToSecondVector(expectedArmZeroConfiguration, tempVector.getVector(), rotation);
armZeroJointAngleConfigurationOffset.setRotation(rotation);

相关文章