Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5419 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Oct 22, 2005, 10:55:51 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: MUCH better algorithm for the QuaternionSlerp in PNodes rotate-to function
also updated the Quaternion class, to now hold dot-product and distance

Location:
trunk/src/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/coord/p_node.cc

    r5414 r5419  
    1111   ### File Specific:
    1212   main-programmer: Patrick Boenzli
    13    co-programmer:
     13   co-programmer: Benjamin Grauer
    1414*/
    1515
     
    630630      if (unlikely(this->toDirection != NULL))
    631631      {
    632         Quaternion rotQuat = Quaternion::quatSlerp(Quaternion(), (*this->toDirection / this->relDirection), fabsf(dt)*this->bias);
    633         if (likely(rotQuat.getSpacialAxisAngle() > PNODE_ITERATION_DELTA))
     632        Quaternion rotQuat = Quaternion::quatSlerp(this->relDirection,*this->toDirection, fabsf(dt)*this->bias);
     633        if (this->relDirection.distance(rotQuat) >PNODE_ITERATION_DELTA)
    634634        {
    635           this->shiftDir(rotQuat);
     635          this->relDirection = rotQuat;
     636          this->bRelDirChanged;
    636637        }
    637638        else
  • trunk/src/lib/graphics/text_engine/text.cc

    r5418 r5419  
    251251        {
    252252          glBegin(GL_QUADS);
     253
    253254          glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]);
    254255          glVertex2d(posX, - tmpGlyph->bearingY * this->size);
     256
    255257          glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]);
    256258          glVertex2d(posX, (tmpGlyph->height - tmpGlyph->bearingY)*this->size);
     259
    257260          glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]);
    258261          glVertex2d(posX+tmpGlyph->width*this->size, (tmpGlyph->height - tmpGlyph->bearingY)*this->size);
     262
    259263          glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
    260264          glVertex2d(posX+tmpGlyph->width*this->size, - tmpGlyph->bearingY*this->size);
     265
    261266          glEnd();
    262267          glEndList();
    263           posX += tmpGlyph->width*this->size;
     268          posX += tmpGlyph->advance * this->size;
    264269        }
    265         tmpText++;
     270        ++tmpText;
    266271      }
    267272    }
  • trunk/src/lib/math/vector.h

    r5215 r5419  
    157157  /** @returns the inverted Quaterntion of this */
    158158  inline Quaternion inverse () const { return conjugate() / (w*w + v.x*v.x + v.y*v.y + v.z*v.z); };
     159  /** @returns the dot Product of a Quaternion */
     160  inline float dot (const Quaternion& q) const { return v.x*q.v.x + v.y*q.v.y + v.z*q.v.z + w*q.w; };
     161  /** @retuns the Distance between two Quaternions */
     162  inline float distance(const Quaternion& q) const { return 2*acos(fabsf(this->dot(q))); };
    159163  /** @param v: the Vector  @return a new Vector representing v rotated by the Quaternion */
    160164  inline Vector apply (const Vector& v) const { return (*this * Quaternion(v, 0) * conjugate()).v; };
Note: See TracChangeset for help on using the changeset viewer.