Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7711 in orxonox.OLD for trunk/src/lib/math


Ignore:
Timestamp:
May 18, 2006, 11:44:21 PM (19 years ago)
Author:
patrick
Message:

trunk: merged the cd branche back to trunk

Location:
trunk/src/lib/math
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/math/matrix.cc

    r5696 r7711  
    244244
    245245    eigVc3 = eigVc1.cross(eigVc2);
     246
     247    eigVc2 = eigVc3.cross(eigVc1);
    246248  }
    247249  else if (eigenValuesCount == 1)
     
    254256  eigVc2.normalize();
    255257  eigVc3.normalize();
     258
     259  if (!(eigVc1.cross(eigVc3) == eigVc2))
     260  {
     261    eigVc3.cross(eigVc1);
     262//     eigVc2.debug();
     263  }
     264/*  printf("ok\n")*/;
    256265}
    257266
  • trunk/src/lib/math/plane.cc

    r6617 r7711  
    222222}
    223223
     224
    224225/**
    225226 *  calculate the two points of minimal distance of two lines
     
    267268{
    268269  n = (a-b).cross(c-b);
    269   k = -(n.x*b.x+n.y*b.y+n.z*b.z);
     270  k = n.dot(a) / n.len();
    270271}
    271272
     
    278279{
    279280  n = norm;
    280   k = -(n.x*p.x+n.y*p.y+n.z*p.z);
     281  k = n.dot(p) / n.len();
    281282}
    282283
     
    291292  Vector p(g[0], g[1], g[2]);
    292293  n = norm;
    293   k = -(n.x*p.x+n.y*p.y+n.z*p.z);
     294  k = n.dot(p) / n.len();
    294295}
    295296
     
    315316  float l = n.len();
    316317  if( l == 0.0) return 0.0;
    317   return (n.dot(p) + k) / n.len();
     318  return (n.dot(p) / n.len() - k);
    318319}
    319320
     
    324325 * @return the distance between the plane and the point (can be negative)
    325326 */
    326 float Plane::distancePoint (const sVec3D& p) const
     327// float Plane::distancePoint (const sVec3D& p) const
     328// {
     329//   Vector s(p[0], p[1], p[2]);
     330//   float l = n.len();
     331//   if( l == 0.0) return 0.0;
     332//   return (n.dot(s) + k) / n.len();
     333// }
     334
     335
     336/**
     337 *  returns the distance between the plane and a point
     338 * @param p: a Point
     339 * @return the distance between the plane and the point (can be negative)
     340 */
     341float Plane::distancePoint (const float* p) const
    327342{
    328343  Vector s(p[0], p[1], p[2]);
     344
    329345  float l = n.len();
    330346  if( l == 0.0) return 0.0;
    331   return (n.dot(s) + k) / n.len();
     347  return (n.dot(s) / n.len() - k);
    332348}
    333349
  • trunk/src/lib/math/plane.h

    r6617 r7711  
    5151  Vector intersectLine (const Line& l) const;
    5252  float distancePoint (const Vector& p) const;
    53   float distancePoint (const sVec3D& p) const;
     53//   float distancePoint (const sVec3D& p) const;
     54  float distancePoint (const float* p) const;
    5455  float locatePoint (const Vector& p) const;
    5556};
  • trunk/src/lib/math/vector.h

    r7191 r7711  
    8585  /** copy constructor* @param v the sVec3D to assign to this vector. @returns the vector v */
    8686  inline const Vector& operator= (const sVec3D& v) { this->x = v[0]; this->y = v[1]; this->z = v[2]; }
     87  inline const Vector& operator= (const float* v) { this->x = v[0]; this->y = v[1]; this->z = v[2]; }
    8788  /** @param v: the other vector \return the dot product of the vectors */
    8889  float dot (const Vector& v) const { return x*v.x+y*v.y+z*v.z; };
Note: See TracChangeset for help on using the changeset viewer.