I want to fire a projectile towards moving target, and to do so I need to find position to aim for.

Target position and velocity is known, as well as gun position and projectile speed (assume constant speed).
What is the best (performence) method to do this task?
I tried to search some resources, and there is a lot of dead links. I found two working methods, but I am unable to understand how they work. The first one look like this:
private Vector3 predictedPosition(Vector3 targetPosition, Vector3 shooterPosition, Vector3 targetVelocity, float projectileSpeed)
{
Vector3 displacement = targetPosition - shooterPosition;
float targetMoveAngle = Vector3.Angle(-displacement, targetVelocity) * Mathf.Deg2Rad;
//if the target is stopping or if it is impossible for the projectile to catch up with the target (Sine Formula)
if (targetVelocity.magnitude == 0 || targetVelocity.magnitude > projectileSpeed && Mathf.Sin(targetMoveAngle) / projectileSpeed > Mathf.Cos(targetMoveAngle) / targetVelocity.magnitude)
{
Debug.Log("Position prediction is not feasible.");
return targetPosition;
}
//also Sine Formula
float shootAngle = Mathf.Asin(Mathf.Sin(targetMoveAngle) * targetVelocity.magnitude / projectileSpeed);
return targetPosition + targetVelocity * displacement.magnitude / Mathf.Sin(Mathf.PI - targetMoveAngle - shootAngle) * Mathf.Sin(shootAngle) / targetVelocity.magnitude;
}
I understand velocity and projectile speed check, but for example I don’t get the part with sine/cosine. Anyway the thing is it looks quite expansive even when optimized, so I wanted to do better and I think there is faster method in this article, but my little brain don’t understand the equation, or rather from where it comes exactly, why those factors are used as a,b,c, plus I am curious if there is even better method than this.
protected float AimAhead(Vector3 delta, Vector3 vr, float muzzleV)
{
// Quadratic equation coefficients a*t^2 + b*t + c = 0
float a = Vector3.Dot(vr, vr) - muzzleV * muzzleV;
float b = 2f * Vector3.Dot(vr, delta);
float c = Vector3.Dot(delta, delta);
float det = b * b - 4f * a * c;
// If the determinant is negative, then there is no solution
if (det > 0f)
{
return 2f * c / (Mathf.Sqrt(det) - b);
}
else
{
return -1f;
}
}