You can use this:
var x = new Vector(1, 0); Vector rotated = Vector.Multiply(x, matrix); double angleBetween = Vector.AngleBetween(x, rotated);
The idea is this:
- We create tempvector (1,0)
- We apply the matrix transformation to the vector and get a rotating time vector
- Calculate the angle between the original and the rotating time vector
You can play with this:
[TestCase(0,0)] [TestCase(90,90)] [TestCase(180,180)] [TestCase(270,-90)] [TestCase(-90, -90)] public void GetAngleTest(int angle, int expected) { var matrix = new RotateTransform(angle).Value; var x = new Vector(1, 0); Vector rotated = Vector.Multiply(x, matrix); double angleBetween = Vector.AngleBetween(x, rotated); Assert.AreEqual(expected,(int)angleBetween); }
Johan larsson
source share