Guest User

Untitled

a guest
Feb 20th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.21 KB | None | 0 0
  1. void meltIce(char a, float state[12], float otherstate[12], unsigned char time) {
  2.     float c[3]={0,-0.35,-0.2},att[3],otherdist[3];
  3.     char i;
  4.     for (i=0;i<3;i++) {
  5.         att[i]=c[i]-state[i];
  6.     otherdist[i]=othrstate[i]-state[i];
  7.     }
  8.  
  9.     if(a==2) { /* revolve */
  10.  
  11.     if(mathVecMagnitude(att, 3)<0.4) { //si posiziona a 40 cm dall'asteroide, se è più vicino, rimane lì
  12.         c[0]=state[0];
  13.         c[1]=state[1];  //la coordinata z deve essere cmq -0.2
  14.     }
  15.     if (mathVecMagnitude(otherdist, 3)<0.25) { //se siamo troppo vicini all'avversario
  16.             //allontaniamoci, ma sempre puntando verso opulens
  17.         for (i=0;i<3;i++)
  18.             c[i]=att[i]-otherdist[i]+state[i];
  19.         }
  20.         if (checkAligned(state) && time>60)
  21.             Plaser ();
  22.     }
  23.     else {  /* spinning */
  24.     c[2]=-0.05;
  25.         if (checkAligned(state) && time>60)
  26.             Plaser ();
  27.         //z=1;
  28.     }    ZRSetPositionTarget(c);
  29.     ZRSetAttitudeTarget (att);
  30. }
  31.  
  32. char checkAligned(float state[12]) {
  33.     char i;
  34.     state[0]*=-1;
  35.     state[1]=-0.35-state[1];
  36.     state[2]=-0.2-state[2];
  37.     mathVecNormalize(state,3);
  38.     for (i=0;i<3;i++)
  39.         state[i]-=state[6+i];
  40.     return (mathVecMagnitude(state,3)<0.12075);
  41. }
Add Comment
Please, Sign In to add comment