I have a triangle that i am trying to rotate(on 2D plain). I calculated it's centroid so, now i have an imaginary circle with center(centroid),points at 0 degree angle (1st vertex of the trangle). My idea is to rotate each vertex by increasing it's angle(on a loop) and finding new coordinates for the vertex at that angle.
#include <stdio.h>
#include <math.h>
//"the function"
int calculate_new_vertex_for_trangle(int center_x, int center_y,int x_at_0,int y_at_0,int angle)
{
double radius = sqrt(pow(x_at_0-center_x,2)+pow(y_at_0-center_y,2));
float angle_to_radian = ((22.0/7.0)/180)*angle;
// googled formula
float new_x = center_x + radius*cos(angle_to_radian);
float new_y = center_y + radius*sin(angle_to_radian);
printf("x : %f, y : %f \nradius : %f\n", new_x, new_y,radius);
return 0;
}
But the result I got was :Image
Numbers at the end of the lines are coordinate's position at respective angle i got using "the function".