Foam::displacementLinearMotionMotionSolver::
displacementLinearMotionMotionSolver
(
    const polyMesh& mesh,
    const dictionary& dict
)
:
    points0MotionSolver(mesh, dict, typeName),
    axis_(normalised(vector(coeffDict().lookup("axis")))),
    xFixed_(readScalar(coeffDict().lookup("xFixed"))),
    xMoving_(readScalar(coeffDict().lookup("xMoving"))),
    displacement_(Function1<scalar>::New("displacement", coeffDict()))
{}
示例#2
0
    cMat4 cQuaternion::GetMatrix() const
    {
      cQuaternion normalised(*this);
      normalised.Normalise();

      const float x2 = normalised.x * normalised.x;
      const float y2 = normalised.y * normalised.y;
      const float z2 = normalised.z * normalised.z;
      const float xy = normalised.x * normalised.y;
      const float xz = normalised.x * normalised.z;
      const float yz = normalised.y * normalised.z;
      const float wx = normalised.w * normalised.x;
      const float wy = normalised.w * normalised.y;
      const float wz = normalised.w * normalised.z;

      cMat4 mat;

      // First row
      mat[0] = 1.0f - 2.0f * (y2 + z2);
      mat[1] = 2.0f * (xy - wz);
      mat[2] = 2.0f * (xz + wy);
      mat[3] = 0.0f;

      // Second row
      mat[4] = 2.0f * (xy + wz);
      mat[5] = 1.0f - 2.0f * (x2 + z2);
      mat[6] = 2.0f * (yz - wx);
      mat[7] = 0.0f;

      // Third row
      mat[8] = 2.0f * (xz - wy);
      mat[9] = 2.0f * (yz + wx);
      mat[10] = 1.0f - 2.0f * (x2 + y2);
      mat[11] = 0.0f;

      // Fourth row
      mat[12] = 0.0f;
      mat[13] = 0.0f;
      mat[14] = 0.0f;
      mat[15] = 1.0f;

      return mat;
    }
示例#3
0
文件: main.cpp 项目: CCJY/coliru
int main() {
    constexpr rational<int> test(4, 2);
    constexpr rational<int> normal = normalised(test);
    
    static_assert(normal.numerator() == 2 && normal.denominator() == 1, "...");
}