-1

I have two points on circle. I know degree from center and coordinates of one point. I want find coordinate of the other point. I think need multiply by rotation matrix to find point. How can i do in c++? Is there any function for it?

BenMorel
  • 34,448
  • 50
  • 182
  • 322

1 Answers1

1

you can calculate it directly using x cos(angle) - y sin (angle ) x sin(angle) + y cos (angle )

the cos and sin functions are available in math.h note that the rotation will be in anti clockwise direction and the rotation will be about the origin. 'angle' should be in radians.

if the center of the circle is not located at origin then you'll have to first shift the origin to the center of the circle , apply rotation and shift the origin back again to get the other point

nittoor
  • 113
  • 6
  • so i'll write like newX= x* cos(angle) - y* sin(angle) then it will calculate the correct coordinate, am i right? – user3126199 Apr 17 '14 at 00:07
  • yes newX= x* cos(angle) - y* sin(angle) and newY= x* sin(angle) + y* cos(angle). Just that the rotation will be in anti clockwise direction and angle should be in radians. If you want it in clockwise direction you can do '-angle' – nittoor Apr 17 '14 at 21:42