Given two Vector2s in WORLD SPACE how would i find the rotation to make the first point lookat the second one?

Given two Vector2s in WORLD SPACE how would i find the rotation to make the first point lookat the second one? (Basically unity transform.lookat function)

Hello Potato,
I think you “mathematically” mix up Points and Vectors.
I suggest you try to build a class with Point2 as Position and Vector2 as LookAtDirection.

Then you set the LookAtDirection of Object A to (B.X - A.X | B.Y - A.Y).

You can also normalize that LookAtDirection-Vector with a Methodcall on Vector.Normalize().

Edit:
Sorry i forgot to mention the rotation.
Therefore i would add Vector2 OldLookAtDirection,
And then you can calculate it with this simple formula:
Angle = cos^-1 (scalarproduct of Old and New / Length of New times Length of Old).
Then you know how much the Object “misslooks” the other Object

Edit: Typo

To get a lookat matrix from pointA to pointB you can use Matrix.CreateWorld. This is for 3D though, but you can just set the z-components of the vectors to 0, in which case the upVector needs to be (0,0,1):

Matrix lookat = Matrix.CreateWorld(pointA, pointB - pointA, upVector);

Subtract the difference between the 2 vector2’s into a new vector2
Normalize the new vector2
Then convert the normalised vector into radians
angleFromVector =
(float)Math.Atan2(newvector.X, -newvector.Y)

If I recall correctly you need to use negative for the y