UE4FVector转四元数FQuat单人开发选ue4还是unity
参考⽂章 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 FQuat MakeFromEuler(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();
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论