Accelerometer car steering and screen tilt control function

Hello,

I'm searching for a more convenient way to handle the steering control and horizon screen tilt.

At the moment I'm using this function as the base for my car steering:

public static float RotationYXAngle180Degree(Vector3 currentAcc)
{
    float rotationAngle = Mathf.Rad2Deg * Mathf.Atan2(currentAcc.y, currentAcc.x);

    return rotationAngle;
}

For the screen horizon tilt I'm using as the base this function:

public static float RotationYXAngle360Degree(Vector3 currentAcc)
{
    float rotationAngle = Mathf.Rad2Deg * Mathf.Atan2(currentAcc.y, currentAcc.x);

    if (rotationAngle < 0f)
        rotationAngle = rotationAngle + 360.0f;

    return rotationAngle;
}

The Vectors are calibrated with an 4x4 Matrix. Here arises already a part of my problem. If I play the game lying on my back then the screen is tilt 180 degree in the wrong direction and the car will steer the wrong way. I tried before to use only the accelerometers Y axis, It just didn't respond well.

A new solution or direction to my problem is greatly welcome ;-).

Peter.

Since this question still at the top o the unanswered questions I hereby answer it... Hopefully it will be marked as answered soon....

I found my own answer ;-) I have changed the the following line of code in both functions: float rotationAngle = Mathf.Rad2Deg * Mathf.Atan2(currentAcc.y, currentAcc.x); to: float rotationAngle = Mathf.Rad2Deg * Mathf.Atan2(currentAcc.y, Mathf.Abs(currentAcc.x)); The Mathf.Abs function makes the Matrix unnecessary. TriplePAF Jan 9 at 0:19

Changed this line in both functions:

float rotationAngle = Mathf.Rad2Deg * Mathf.Atan2(currentAcc.y, currentAcc.x);

with

 float rotationAngle = Mathf.Rad2Deg * Mathf.Atan2(currentAcc.y, Mathf.Abs(currentAcc.x));