Hilfe kann keine Formel umstellen!



  • Hi!
    Ich hab versucht ne SinusInterpolationsFormel nach c umzustellen aber irgendwas hab ich falsch gemacht und ich raffs nich 😕 😡 😞

    float cosine (float valA, float valB, float c) // Interpolierten Wert i berechnen
    {
    	float angle = c * D3DX_PI;
    	float prc = (1.0f - cos(angle)) * 0.5f;
    	return  valA * (1.0f - prc) + valB * prc;
    }
    
    float Cosine_GetC (float valI, float valA, float valB) // c berechnen wenn i bekannt ist
    {
    	float prc = (valI - valA) / valB;
    	float angle = acosf(1.0f - (prc / 0.5f));
    	float c = angle / D3DX_PI;
    
    	return c;
    
    }
    

    und das kommt dann dabei raus.

    float i = cosine (1.5f, 2.0f,	0.3f);   // i = 1.6030538
    float c = Cosine_GetC (i, 1.5f, 2.0f);   // c = 0.14578046  sollte 0.3 sein
    
    float i2 = cosine (2.0f, 1.5f, 	0.3f);   // i2 = 1.8969464
    float c2 = Cosine_GetC (i, 2.0f, 1.5f);  // c2 = -1.#IND000 sollte 0.3 sein
    

    kopfloses hin- und her probieren hilft nicht weiter. Kann ich hiermit bestätigen...

    Kann mir büdde jemand nachhilfe geben?



  • Zeile 10 ist falsch:

    float prc = (valI - valA) / (valB - valA);
    

    Kannst du mal sagen, wozu man das braucht?


Anmelden zum Antworten