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
Toshihiro Shimizu 890ddd
void IKNode::computeS(void)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	IKNode *y = this->getParent();
Toshihiro Shimizu 890ddd
	IKNode *w = this;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	s = r; // Initialize to local (relative) position
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	while (y) {
Toshihiro Shimizu 890ddd
		s = rotatePoint(s, y->theta);
Toshihiro Shimizu 890ddd
		y = y->getParent();
Toshihiro Shimizu 890ddd
		w = w->getParent();
Toshihiro Shimizu 890ddd
		s += w->r;
Toshihiro Shimizu 890ddd
		m_pos = s;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void IKNode::setPurpose(Purpose purpose)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_purpose = purpose;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TPointD rotatePoint(TPointD &point, double theta)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	double costheta = cos(theta);
Toshihiro Shimizu 890ddd
	double sintheta = sin(theta);
Toshihiro Shimizu 890ddd
	double tempx = point.x * costheta - point.y * sintheta;
Toshihiro Shimizu 890ddd
	point.y = point.y * costheta + point.x * sintheta;
Toshihiro Shimizu 890ddd
	point.x = tempx;
Toshihiro Shimizu 890ddd
	return point;
Toshihiro Shimizu 890ddd
}