SGolaySmoothingFilter::SGolaySmoothingFilter(int size, int degree)
    : m_windowSize(size + (size + 1) % 2),
      m_degree(degree),
      m_values(VectorN(0.0, degree)),
      m_windowData(VectorN(0.0, m_windowSize)),
      m_coeffMatrix(MatrixN(0.0, m_degree + 1, m_windowSize))
{
    // initialize matrix of coefficients
    MatrixN designMatrix(1.0, m_windowSize, m_degree + 1);

    // generate a vector of the intervals across the window, centered at zero,
    // each vector is raised to the power of its column index. note the first
    // column is skipped because a^0 is always 1 and the matrix has been
    // initialized to 1.

    for(int row = 0; row < m_windowSize; row++) {
        for(int col = 1; col < m_degree + 1; col++) {
            double base = row - (m_windowSize - 1);
            designMatrix[row][col] = std::pow(base, col);
        }
    }

    MatrixN JxJT = (designMatrix.transpose() * designMatrix);
    m_coeffMatrix = JxJT.inverse() * designMatrix.transpose();
}
Пример #2
0
 /** Get a unit vector perpendicular to this one. */
 VectorN getOrthogonalDirection() const
 {
   return ((this->maxAbsAxis() == 0) ? VectorN(y(), -x(), 0) : VectorN(0, z(), -y())).unit();
 }
Пример #3
0
 /** Swizzle operator, returns ZZZ. */
 VectorN zzz() const { return VectorN   (z(), z(), z()); }
Пример #4
0
 /** Cross-product of this vector with another. */
 VectorN cross(VectorN const & rhs) const
 {
   return VectorN((*this)[1] * rhs[2] - (*this)[2] * rhs[1],
                  (*this)[2] * rhs[0] - (*this)[0] * rhs[2],
                  (*this)[0] * rhs[1] - (*this)[1] * rhs[0]);
 }
Пример #5
0
 /** Swizzle operator, returns XZZ. */
 VectorN xzz() const { return VectorN   (x(), z(), z()); }
Пример #6
0
 /** Swizzle operator, returns YZZ. */
 VectorN yzz() const { return VectorN   (y(), z(), z()); }
Пример #7
0
 /** Swizzle operator, returns YYZ. */
 VectorN yyz() const { return VectorN   (y(), y(), z()); }
Пример #8
0
 /** Swizzle operator, returns ZYZ. */
 VectorN zyz() const { return VectorN   (z(), y(), z()); }
Пример #9
0
 /** Swizzle operator, returns ZXZ. */
 VectorN zxz() const { return VectorN   (z(), x(), z()); }
Пример #10
0
 /** Swizzle operator, returns XYZ. */
 VectorN xyz() const { return VectorN   (x(), y(), z()); }
Пример #11
0
 /** Swizzle operator, returns YXZ. */
 VectorN yxz() const { return VectorN   (y(), x(), z()); }
Пример #12
0
 /** Swizzle operator, returns XXZ. */
 VectorN xxz() const { return VectorN   (x(), x(), z()); }
Пример #13
0
 /** Swizzle operator, returns ZXY. */
 VectorN zxy() const { return VectorN   (z(), x(), y()); }
Пример #14
0
 /** Swizzle operator, returns YXY. */
 VectorN yxy() const { return VectorN   (y(), x(), y()); }
Пример #15
0
 /** Swizzle operator, returns XXY. */
 VectorN xxy() const { return VectorN   (x(), x(), y()); }