//
// Computes the surface angle deviation, from the splines orientation.. Funky stuff!
// ! In degrees !
public float GetSurfaceAngleAtTime(float time)
{
if (spline == null)
{
return(0.0f);
}
float angle = 0.0f;
Vector3 pos0 = spline.GetPositionAtTime(time);
float rad0 = group.GetRadiusAtTime(this, time, false);
if (time < 0.5f)
{
float difPos = (spline.GetPositionAtTime(time + 0.01f) - pos0).magnitude;
float difRad = group.GetRadiusAtTime(this, time + 0.01f, false) - rad0;
angle = Mathf.Atan2(difRad, difPos);
}
else
{
float disPos = (pos0 - spline.GetPositionAtTime(time - 0.01f)).magnitude;
float difRad = rad0 - group.GetRadiusAtTime(this, time - 0.01f, false);
angle = Mathf.Atan2(difRad, disPos);
}
return(angle * Mathf.Rad2Deg);
}