Ignore:
Timestamp:
Aug 20, 2009, 11:35:19 AM (16 years ago)
Author:
Saskia Metzler <metzler@…>
Children:
bc3953
Parents:
84b811
Message:

Ticket 16: Unit tests for Vector::RotateVector(), additionally fixing the function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/vector.cpp

    r84b811 r6c6d84  
    467467};
    468468
    469 /** Rotates the vector around the axis given by \a *axis by an angle of \a alpha.
     469/** Rotates the vector relative to the origin around the axis given by \a *axis by an angle of \a alpha.
    470470 * \param *axis rotation axis
    471471 * \param alpha rotation angle in radian
     
    478478  a.ProjectOntoPlane(axis);
    479479  // construct normal vector
    480   y.MakeNormalVector(axis,this);
     480  bool rotatable = y.MakeNormalVector(axis,&a);
     481  // The normal vector cannot be created if there is linar dependency.
     482  // Then the vector to rotate is on the axis and any rotation leads to the vector itself.
     483  if (!rotatable) {
     484    return;
     485  }
    481486  y.Scale(Norm());
    482487  // scale normal vector by sine and this vector by cosine
    483488  y.Scale(sin(alpha));
    484   Scale(cos(alpha));
     489  a.Scale(cos(alpha));
     490  CopyVector(Projection(axis));
    485491  // add scaled normal vector onto this vector
    486492  AddVector(&y);
Note: See TracChangeset for help on using the changeset viewer.