【问题标题】:Unity's 'Vector3.Slerp' equivalent in Unreal Engine 4 C++?Unity 在 Unreal Engine 4 C++ 中的“Vector3.Slerp”等价物?
【发布时间】:2020-06-07 06:02:11
【问题描述】:

UE4 C++ 是否有类似Vector3.Slerp 的内置函数?

如果没有,是否有“虚幻优化方式”来做到这一点?
我有 2 个向量,我想在圆弧路径上获得它们之间的一些位置。

【问题讨论】:

标签: c++ unreal-engine4


【解决方案1】:

我会像这样实现向量 slerp 方程 (see wikipedia page):

static FVector Slerp(const FVector& a, const FVector& b, const float t)
{
    float omega = FGenericPlatformMath::Acos(FVector::DotProduct(
            a.GetSafeNormal(), 
            b.GetSafeNormal()
            ));
    float sinOmega = FGenericPlatformMath::Sin(omega);
    FVector termOne = a * (FGenericPlatformMath::Sin(omega * (1.0 - t)) / sinOmega);
    FVector termTwo = b * (FGenericPlatformMath::Sin(omega * (      t)) / sinOmega);
    return termOne + termTwo;
}

【讨论】:

    猜你喜欢
    • 2020-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-10
    • 2011-04-02
    • 2021-10-15
    相关资源
    最近更新 更多