UE4 FVector转四元数FQuat

参考文章 Unity3D中的Quaternion(四元数)点击打开链接


UE4中找了好久终于发现相关函数:翻译来自有道 哈哈

/*
* Convert a vector of floating-point Euler angles (in degrees) into a Quaternion. 将浮点欧拉角的一个矢量转换成四元数。
* @param Euler the Euler angles 对欧拉角进行分析
* @return constructed FQuat 返回构造FQuat
*/

static CORE_API FQuatMakeFromEuler(const FVector&Euler);


使用:

FVector vec = FVector(0,0,45);
FQuat quat = FQuat::MakeFromEuler(vec);



/**
 * Return the Quaternion orientation corresponding to the direction in which the vector points.
 	返回与矢量点方向对应的四元数方向。
 
 * Similar to the FRotator version, returns a result without roll such that it preserves the up vector.
	类似于FRotator版本,返回一个没有滚动的结果,这样它就保留了向上的向量。
 * @note If you don't care about preserving the up vector and just want the most direct rotation, you can use the faster
 * 'FQuat::FindBetweenVectors(FVector::ForwardVector, YourVector)' or 'FQuat::FindBetweenNormals(...)' if you know the vector is of unit length.

注意,如果你不关心保持向上的向量,只需要最直接的旋转,你就可以用得更快

“FQuat::FindBetweenVectors(FVector::ForwardVector YourVector)”或“FQuat:FindBetweenNormals(…)如果你知道向量的单位长度。

* @return Quaternion from the Vector's direction, without any roll.
@return Quaternion从矢量方向,没有任何滚动。
 
 * @see ToOrientationRotator(), FQuat::FindBetweenVectors()
 */
CORE_API FQuat ToOrientationQuat() const;


使用:

FVector v(0, 0, 40);
auto q = v.ToOrientationQuat();





  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值