コード例 #1
0
TThickPoint TStrokeBenderDeformation::getDisplacement(const TStroke &s,
                                                      double w) const {
  // potenziale exp^(-x^2) limitato tra
  // [-c_maxLenghtOfGaussian,c_maxLenghtOfGaussian]
  double strokeLengthAtParameter = s.getLength(w);
  double diff                    = strokeLengthAtParameter - m_startLength;

  if (m_vect) {
    double outVal = 0.0;

    if (fabs(diff) <= m_lengthOfDeformation)
      if (m_versus == INNER) {
        diff *= (1.0 / m_lengthOfDeformation) * c_maxLenghtOfGaussian;
        outVal = gaussianPotential(diff);
      } else if (m_versus == OUTER) {
        double valForGaussian = -c_maxLenghtOfGaussian +
                                2 * c_maxLenghtOfGaussian /
                                    m_lengthOfDeformation *
                                    strokeLengthAtParameter;
        outVal = 1.0 - gaussianPotential(valForGaussian);
      }

    TPointD cp = convert(s.getControlPointAtParameter(w));
    TPointD p  = cp;

    TRotation rot(*m_vect, outVal * rad2degree(m_angle));

    p = rot * p;

    return TThickPoint(p - cp, 0.0);
  }

  return TThickPoint();
}
コード例 #2
0
TThickPoint TStrokeTwirlDeformation::getDisplacement(const TStroke &stroke,
                                                     double s) const {
  double outVal = 0;

  double distance2 =
      tdistance2(convert(stroke.getControlPointAtParameter(s)), m_center);

  if (distance2 <= m_innerRadius2)
    outVal = wyvillPotential(distance2, m_innerRadius2);

  return TThickPoint(m_vectorOfMovement * outVal, 0);
}
コード例 #3
0
double TStrokePointDeformation::getDelta(const TStroke &stroke,
                                         double w) const {
  // reference to a thickpoint
  TThickPoint thickPnt = m_imp->m_vect ? stroke.getControlPointAtParameter(w)
                                       : stroke.getThickPoint(w);

  assert(thickPnt != TConsts::natp);

  TPointD pntOfStroke = convert(thickPnt);

  double d = tdistance(pntOfStroke, m_imp->m_circleCenter);

  return m_imp->m_potential->gradient(d);
}
コード例 #4
0
TThickPoint TStrokePointDeformation::getDisplacement(const TStroke &stroke,
                                                     double w) const {
  // riferimento ad un punto ciccione della stroke
  TThickPoint thickPnt = m_imp->m_vect ? stroke.getControlPointAtParameter(w)
                                       : stroke.getThickPoint(w);

  assert(thickPnt != TConsts::natp);

  TPointD pntOfStroke(convert(thickPnt));

  double d = tdistance(pntOfStroke, m_imp->m_circleCenter);

  if (m_imp->m_vect)
    return m_imp->m_potential->value(d) * TThickPoint(*m_imp->m_vect, 0);
  else {
    double outVal = m_imp->m_potential->value(d);

    return TThickPoint(outVal, outVal, 0);
  }
}