2017-02-14 4 views
-1

De ce code, j'ai un problème avec la méthode sqrt, sin & car je n'arrive pas à résoudre le problème et l'EPSILON ne peut pas résoudre le symbole. Ai-je besoin d'ajouter dans la bibliothèque de maths pour le sin cos & sqrt? Si oui pouvez-vous me donner le lien pour télécharger le pot?Problème avec la méthode et le symbole qui ne peuvent pas être résolus

float omegaMagnitude = sqrt(axisX*axisX + axisY*axisY + axisZ*axisZ); 

     // Normalize the rotation vector if it's big enough to get the axis 
     // (that is, EPSILON should represent your maximum allowable margin of error) 
     if (omegaMagnitude > EPSILON) { 
      axisX /= omegaMagnitude; 
      axisY /= omegaMagnitude; 
      axisZ /= omegaMagnitude; 
     } 

     // Integrate around this axis with the angular speed by the timestep 
     // in order to get a delta rotation from this sample over the timestep 
     // We will convert this axis-angle representation of the delta rotation 
     // into a quaternion before turning it into the rotation matrix. 
     float thetaOverTwo = omegaMagnitude * dT/2.0f; 
     float sinThetaOverTwo = sin(thetaOverTwo); 
     float cosThetaOverTwo = cos(thetaOverTwo); 
+1

JAR? C'est Java? Ceux-ci devraient être Math.sqrt, Math.sin et Math.cos. EPSILON devrait être défini comme un double par vous. Aucune bibliothèque nécessaire. – duffymo

+0

Je soupçonne que le code que vous avez copié et collé a 'import static java.lang.Math.sqrt;' (et même pour les autres fonctions, et similaire pour la constante EPSILON). –

+0

J'ai essayé d'utiliser l'import static java.lang.Math.sqrt; mais le flotteur omegaMagnitude = sqrt (axeX * axeX + axeY * axeY + axeZ * axeZ); est souligné en rouge. Pour l'EPSILON je ne sais pas trop comment le définir comme double. – MdZain

Répondre

0

Vous n'avez pas besoin de télécharger de bibliothèques supplémentaires. Utilisez Math.sin(x), Math.cos(x) and Math.sqrt(x) ou sin(x), cos(x) and sqrt(x) et placez le code suivant en haut de votre fichier (mais au-dessous de la ligne package [...], si elle existe):

// For Math.xxx() 
import java.lang.Math; 

// For xxx() 
import static java.lang.Math.sin; 
import static java.lang.Math.cos; 
import static java.lang.Math.sqrt; 

Si vous utilisez Eclipse appuyez simplement sur Ctrl + Shift + O pour organiser automatiquement vos importations (il devrait y avoir des raccourcis similaires pour d'autres IDE).