Rotating a sprite and getting the new point and rotation

I originally posted this as Rotation & Radians and completely munged up the question. I’ll try to rephrase everything. Given this sprite:
111

NOTE: that location / point is the very tip of the arrowhead. I want to rotate this sprite 180 degrees and I need to know what the new point and rotation value is. Also note: the center of the sprite, for rotation purposes would be the length of the arrowhead - where the two lines intersect. Again, this would be a LOT easier if the drawing point of the sprite would be the center and not the tip of the arrowhead.

I’m not sure how you’re doing the rotation to start with, but you can create a matrix that is a combination of a translation (of the rotation point to the origin), a rotation (about the new origin), and a translation back to where the point of rotation was. Then you can apply that rotation matrix to the point itself.

The Matrix class has Create methods that you can use for these, I believe, then you multiply them together to create the transformation matrix, which you then multiply the point by. If you’re doing this in 2D, just use the x and y coordinates while setting the Z value to zero, and rotate around the Z-axis for your rotation.

Let me know how it goes :slight_smile:

1 Like

Wrote a rotation simulator for your simulator.

https://dotnetfiddle.net/7mYXsn

Discovered this site the other day and wanted to test it out.

I had to make a few changes for my purposes, but YES!!!
I owe you big time!
Can I send you a Steam key for the game (the editor bundle is already out on Steam)? Send me an email to Ezra@RiverviewAI.com and I’ll get you a free Steam key.

1 Like

No problem, I’m glad it worked.

The way Trinith mentioned using Matrix.CreateRotationZ works as well. The DrawUnit method in my console draw code was actually already using Matrix.CreateRotationZ too.

Thanks for the offer. I’m quite busy at the moment so unfortunately I might not get to play it properly for a while. I noticed there is a chat function on these forums now so I’ll send a message through that to try it out. If it doesn’t work I’ll email.

I am interested in knowing if posting code on that website with the interactive grid/input cycle helped more than just posting code here. I might try to utilize it more as it allows issues/solutions to be demonstrated quickly and for anyone to experiment further without setting up a project, copy/paste code, etc.

1 Like