As far as I understand your requirements,
1. You want to store a set of points in a tree, not necessarily balanced.
2. You want to be able to rotate any sub-tree about its root point, by any angle
3. You want to find the final coordinates of any point after after a set of rotation operations as specified above.
Since we'll be storing 2D points in a tree structure, I'll be using a point QuadTree approach to store the points. Let the structure of a node of the tree be as follows: $ Node := (x,y,\theta,q1,q2,q3,q4,parent)$. Where
* $x,y$ is the co-ordinate of a point.
* $\theta$ is the resultant angle by which the point's tree has been rotated to after an arbitrary number of rotation operations.
* $q1,q2,q3,q4$ are pointers to the quadrants with respect to $(x,y)$.
* $parent$ is a pointer to the parent node.
Functions for the QuadTree
1. 953
$insertPoint(x,y)$
This would be a standard QuadTree insertion algorithm while setting $\theta=0$ for the newly inserted node.
2. $searchPoint(x,y)$
This would search the QuadTree for a node representing $(x,y)$ and return a pointer to it. This will be used ahead.
3. $rotatePoint(x,y,\theta)$
This would be a standard QuadTree search for $(x,y)$. Then upon finding the particular node, set $node.\theta = node.\theta + \theta$ i.e. add and store the rotation angle into the $\theta$ value already in the node.
4. $calculateResultantCoordinates(x,y)$
This is where the magic happens.
This function will return a $(x',y')$ pair consisting of the resultant co-ordinates of the $(x,y)$ passed to the function.
pseudo-code
calculateResultantCoordinates(x,y)
{
n = searchFor(x,y)
if (n is null)
// error handling
(x,y)=(n.x,n.y)
while ( n.parent != null )
{
if ( n.parent.theta == 0 )
continue
x = x - n.parent.x
y = y - n.parent.y
// (x,y) now represent a complex number (x + j*y)
// rotating a complex number can be done by multiplying it with $e^{j*\theta}$ = $cos(\theta) + j*sin(\theta)$
// the resultant point is
// $(x*cos(\theta)-y*sin(\theta),x*sin(\theta)+y*cos(\theta))$
p = x*cos(p.theta) - y*sin(p.theta)
q = x*sin(p.theta) - y*cos(p.theta)
(x,y) = (p,q)
n = n.parent
// traverse the path from leaf to the root node
}
return (x,y)
} 953