Quaternion reverse rotation?

Also ich habe eine Methode, die es vermag, ein raster-position in den globalen Raum:

public Vector3 GridToGlobal(IVector3 gridPos)
{
 Vector3 globalPos = new Vector3(gridPos.x, gridPos.y, gridPos.z);
 globalPos *= Scale;
 globalPos = Container.transform.rotation * globalPos;
 return globalPos;
}

Nun, wenn ich will, tun das Gegenteil, wie würde ich mich über eine rotierende Vektor in raster-Raum ?

public IVector3 GlobalToGrid(Vector3 globalPos)
    {
        globalPos -= Container.transform.position;
        globalPos = Container.transform.rotation * globalPos; //this will obviously rotate in the wrong direction
        globalPos /= Scale;
        return new IVector3((int)Mathf.Round(globalPos.x), (int)Mathf.Round(globalPos.y), (int)Mathf.Round(globalPos.z));
    }

Irgendwelche Ideen?

InformationsquelleAutor pixartist | 2014-04-25

Schreibe einen Kommentar