Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/iknode.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TPointD DVAPI rotatePoint(TPointD &point, double theta);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Compute the global position of a single node
Shinya Kitaoka 120a6e
void IKNode::computeS(void) {
Shinya Kitaoka 120a6e
  IKNode *y = this->getParent();
Shinya Kitaoka 120a6e
  IKNode *w = this;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  s = r;  // Initialize to local (relative) position
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  while (y) {
Shinya Kitaoka 120a6e
    s = rotatePoint(s, y->theta);
Shinya Kitaoka 120a6e
    y = y->getParent();
Shinya Kitaoka 120a6e
    w = w->getParent();
Shinya Kitaoka 120a6e
    s += w->r;
Shinya Kitaoka 120a6e
    m_pos = s;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IKNode::setPurpose(Purpose purpose) { m_purpose = purpose; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TPointD rotatePoint(TPointD &point, double theta) {
Shinya Kitaoka 120a6e
  double costheta = cos(theta);
Shinya Kitaoka 120a6e
  double sintheta = sin(theta);
Shinya Kitaoka 120a6e
  double tempx    = point.x * costheta - point.y * sintheta;
Shinya Kitaoka 120a6e
  point.y         = point.y * costheta + point.x * sintheta;
Shinya Kitaoka 120a6e
  point.x         = tempx;
Shinya Kitaoka 120a6e
  return point;
Toshihiro Shimizu 890ddd
}