I have some code here in C#
//take a world Vector2D and make it a relative Vector2D
public Vector2D WorldToRelative(Vector2D world)
{
Matrix mat = new Matrix();
PointF[] Vectors = new PointF[1];
Vectors[0].X = world.X;
Vectors[0].Y = world.Y;
mat.Rotate(-m_angle / (float)Math.PI * 180.0f);
mat.TransformVectors(Vector2Ds);
return new Vector2D(Vectors[0].X, Vectors[0].Y);
}
The problem is android’s Matrix does not seem to have rotate and transform vector.
It has pre and post rotation and mapping vectors.
What could I do to correctly port this code to android?
Thanks
Android has a great
Matrixclass; just usemMatrix.setRotate()andmMatrix.setTranslate()to do your rotation and translation. If you need to scale, usemMatrix.setScale().A lot of Android functions prefix with ‘set’, so
.rotate()becomes.setRotate(). It just takes a little getting used to!