#include <stdio.h>
#include <math.h> // sin(.), cos(..)
#define PI 3.14159
/*
원점(origin) : O( 0, 0 )
회전할 대상(taget) : T( tx, ty ),
회전중심점(center) : C( cx, cy),
회전후의점(new pt) : N( nx, ny),
주어진 회전중심점 C에 대하여 회전하는 문제는
회전중심점 C가 원점 0와 일치하도록 회전할 점 T를 함께 평행이동한 후
z-축을 중심으로하여 원점 0에서 주어진 각 q만큼 회전하고
다시 원점 0가 처음 주어진 회전중심점 C와 일치하도록 함께 평행이동합니다.*/
void rotate( float* nx, float* ny, float tx, float ty, float cx, float cy, float q )
{
float cosq = cos( q ), sinq = sin( q );
// 회전중심점 C가 원점 O와 일치하도록 회전할 점 T를 함께 평행이동
tx -= cx, ty -= cy;
// 원점 O에 대하여 회전할 점 T를 q라디안 만큼 회전
*nx = tx * cosq - ty * sinq;
*ny = ty * cosq + tx * sinq;
// 원점 O가 원래의 회전 중심점 C와 일치하도록 회전된 점 N과 함께 이동
*nx += cx, *ny += cy;
}
출처 : http://digitalab.pcu.ac.kr/?document_srl=79385&listStyle=webzine&mid=study_etc

