Game Development Community

Point rotation about a second point (2-D)

by Stephen Zepp · in Torque Game Engine · 05/24/2004 (7:47 pm) · 1 replies

Spent not a few hours researching quats and trying to remember my matrix math from 15+ years ago, and still scratching my head hard, so here is my question in a nutshell:

Given a point, x1,y1 and a second point x2,y2, I want to rotate the first point 1 unit (doesn't really matter size) about the circle defined by using x2,y2 as the origin, and r = the distance between the two points in either direction around the circumference.

I can faintly remember this being pretty easy back in the middle ages (when I was in college), but for the life of me I can't figure it out. Any suggestions?

FYI, I'm working on giving the godmode camera in the Advanced Camera tutorial freedom of motion (pitch/yaw about the player, and zoom in/out). I found what may be a pretty neat, if not particularly high performance method by realizing the datablock offset values are exposed to script, and can be changed runtime, so I want to allow for yaw, pitch, and zoom inputs to dynamically calculate the offset. I just need to be able to rotate 2 of the 3 coords at any one time to new cartesians given a fixed radius and unit of arc.

#1
05/24/2004 (9:18 pm)
You can use this equation:

xnew = x * cos(angle) - y * sin(angle)
ynew = y * cos(angle) + x * sin(angle)

thats for rotating around the origin(0,0).. so you would probly have to rotate it then translate it..