Rotation problem

BlitzMax Forums/BlitzMax Programming/Rotation problem

btw: if you intend that to use within a system, I would suggest make a 2x3 matrix out of it :)

Matrix T =  |r*cos(angle)  r*sin(angle)  offsetX|
            |-r*sin(angle) r*cos(angle)  offsetY|
Vector newPos, oldPos, both [X Y 1] component wise

newPos = T * oldPos


This matrix T can be split down to 2 distinct submatrices and save calculation time if you want to use it for hierarchy . (as well, sin and cos can be precalculated)

Multiple transformations down the hierarchy would be as simple as

newPos = T_3 * T_2 * T_1 * oldPos
where T_x refers to the level down the hierarchy (depth) and oldPos is the global position you want to transform through that.