private float GetPenDistance(BallisticMaterial bMaterial, float bulletVelocity, float dragCoefficient)
        {
            var vthr = Mathf.Sqrt(2 * bMaterial.yieldStrength /
                                  (dragCoefficient * (bMaterial.density * 1000)));
            var xc = (_massGram / _area) * (1 / (dragCoefficient * bMaterial.density));

            return(xc * Mathf.Log(1 + Mathf.Pow(bulletVelocity / vthr, 2)));
        }
        private bool CheckForRicochet(BallisticMaterial ballisticMaterial, float penDistance, float angle)
        {
            var sd            = bulletMass / (7000f * bulletDiameter * bulletDiameter);
            var penCoef       = Mathf.Clamp01(1 - (penDistance * Mathf.Pow(sd, 0.25f)));
            var criticalAngle = Mathf.Asin(ballisticMaterial.density / bulletDensity) * Mathf.Rad2Deg;

            criticalAngle = criticalAngle + (criticalAngle * penCoef);
            var currentAngleCoef = Mathf.Log(1 + Mathf.Pow(angle / criticalAngle, 2));
            var maxAngleCoef     = Mathf.Log(1 + Mathf.Pow(90f / criticalAngle, 2));
            var angleCoef        = currentAngleCoef / maxAngleCoef;

            return(Random.Range(sd, 1f) <= 1 - angleCoef);
        }
        private float GetNewVelocity(BallisticMaterial bm, float penDistance)
        {
            var kineticEnergy = (_massKg * (_trueVelocity.magnitude *
                                            _trueVelocity.magnitude)) / 2;
            var dx = penDistance;

            if (_rb.transform.position != Vector3.zero)
            {
                dx = Vector3.Distance(_entryHole, _exitHole);
            }
            var dE = ((_areaMeters * (kineticEnergy / _massKg) *
                       (bm.density * 1000f)) + (bm.yieldStrength / 3 * _areaMeters)) * dx;

            kineticEnergy -= (dE - kineticEnergy);

            return(Mathf.Sqrt((kineticEnergy) / (_massKg * 0.5f)));
        }