English Get X and Y based on rotation

6 replies
Goto Page
To the start Previous 1 Next To the start
08.12.19 07:14:04 am
Up
Goo
User
Offline Off
I have (pixel) X and Y.
I also have a rotation.

I want the X and Y to point at the object.

IMG:https://i.imgur.com/AR24s1N.png


This might explain it better, it's hard for me to explain.
08.12.19 08:20:49 am
Up
Bowlinghead
User
Offline Off
Okay. How can a circle can have a rotation?
And if your result is really this rectangle I dont get how you came to the solution.

So you have a starting point with X,Y and rot? Then you want to see the next objects this point is "watching at"?
More >

I would increment the view distance and check everytime if something is on the way.
Once you hit it you do know c and all angles in my triangle. Then you can get whatever you want.
edited 1×, last 08.12.19 09:16:26 am
Share time limited free games here
08.12.19 10:04:56 am
Up
SQ
Moderator
Offline Off
Probably he means that:

He has Object A and Object B
He wants to set rotation of Object A so it is looking at Object B

Code:
1
rotation = Atan2(objectA.y - objectB.y, objectA.x - objectB.b)


After you get rotation, you can push your old position towards the new one.
Code:
1
2
ObjectA.x + cos(rotation) * distance
ObjectA.y + sin(rotation) * distance
edited 2×, last 08.12.19 11:28:32 am
08.12.19 02:19:36 pm
Up
Goo
User
Offline Off
@user SQ: Thank you! It works like a charm
09.12.19 02:11:51 pm
Up
Goo
User
Offline Off
@user Gaios: what?

This isn't the same formula, is it?
09.12.19 03:43:57 pm
Up
SQ
Moderator
Offline Off
@user Goo: It IS pretty much the same thing. Basic trigonometry.
To the start Previous 1 Next To the start