How is the center vector calculated in this example or in any example. WolframAlpha: http://www.wolframalpha.com/input/?i=rotate+90+degrees+center+%283%2C0%29
Homogenous coordinates:
[ cos(theta) -sin(theta) 0 ]
Rotate = [ sin(theta) cos(theta) 0 ]
[ 0 0 1 ]
[ 1 0 x ]
Translate = [ 0 1 y ]
[ 0 0 1 ]
So to perform your transformation, you multiply Translate(x, y) * Rotate(theta) * Translate(-x, -y)
and get a transformation matrix.
Or in one function statment
Vector RotateAbout(Vector node, Vector center, double angle)
{
return new Vector(
center.X + (node.X-center.X)*COS(angle) - (node.Y-center.Y)*SIN(angle),
center.Y + (node.X-center.X)*SIN(angle) + (node.Y-center.Y)*COS(angle)
};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With