Download

FMath::SinCos in comparison to sinf, cosf

Is there a performance benefit using FMath::SinCos or are there other reasons UE implemented this, like being independent from implementation? Or are sinf/cosf not available at all implementations which UE4 is supporting? The results are same for both (VS2017):


    float amountLong = cosf(angleRad);
    float amountLat = sinf(angleRad);

    float amountLong = {}; float amountLat = {};
    FMath::SinCos(&amountLat, &amountLong, angleRad); // Faster than above? Safer than above regarding different implementations?

There are SIMD intrinsics that will give you both sin/cos for X with a single call. I imagine it’s for that case. Just saves you a method call if you know you are going to need both anyway.

If you want to compare performance, it’s best to just make a quick benchmark. Then you’ll know for sure.

Most modern FPUs give combined SinCos for the same cycles as individual Sin or Cos