tahoma2d/toonz/sources/toonzlib/iknode.cpp

33 lines
756 B
C++
Raw Normal View History

2016-03-19 06:57:51 +13:00
#include "toonz/iknode.h"
TPointD DVAPI rotatePoint(TPointD &point, double theta);
// Compute the global position of a single node
2016-06-15 18:43:10 +12:00
void IKNode::computeS(void) {
IKNode *y = this->getParent();
IKNode *w = this;
s = r; // Initialize to local (relative) position
while (y) {
s = rotatePoint(s, y->theta);
y = y->getParent();
w = w->getParent();
s += w->r;
m_pos = s;
}
2016-03-19 06:57:51 +13:00
}
2016-06-15 18:43:10 +12:00
void IKNode::setPurpose(Purpose purpose) { m_purpose = purpose; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TPointD rotatePoint(TPointD &point, double theta) {
double costheta = cos(theta);
double sintheta = sin(theta);
double tempx = point.x * costheta - point.y * sintheta;
point.y = point.y * costheta + point.x * sintheta;
point.x = tempx;
return point;
2016-03-19 06:57:51 +13:00
}