Problems with Arbitary Rotation about a Point

Hi Folks,

   I have a some point on 3d Space which lie on xy plane ,I need to rotate those point with respect to a point which acts as a center even this point stays on the same plane.

 I got lots of Algorithms Online for arbitary rotaions in 3D and 2D spaces , but i was not able to rotate the points correctly in any case .

my newB = B x { {(-A)x(RM)}*(+A)}

and the -A looks like

 { 1   0   0  0 ,
   0   1   0  0 ,
   0   0   1  0 ,
  -xa -ya -za 1 }  


      cos(ang)   -sin(ang)  0   0   ,
      sin(ang)    cos(ang)  0   0   ,   
      0               0     1   0   ,
      0               0     0   1  }  

I was able to rotate about the point but the new rotated points are scaled down to the center.

All I need from You is if any one feels tht u have time for me explain me the below.

– How to rotate a point B ( xb ,yb ,zb)
with respect to point A ( Xa ya za)

along with phi angle along z axis in 3D

please give me the correct matrices to
multiple to get the transformed B values

importantly specify the multiplication order which matrices to multiply and how to multiply (i mean AxB OR BXA )

  • kumar .k

You are asking for something quite simple, so I will
explain what you need to get it done.

When you rotate vectors (a point in 3D space (x,y,z))
you rotate about the origin (0,0,0). To perform a
rotation about an arbitrary point, you need to move
your world such that the arbitrary point is at the
origin, then rotate the original vector as you would
normally about the (0,0,0) point, and then translate
the result back such that the arbitrary point is at
its original location.

So if you have point P and an arbitrary point C
about which you want to rotate P, you need an
operator (matrix) T that translates vectors, an
operator R which rotates vectors, and another
operator S which translates vectors.

T will look like this:
1 0 0 dx
0 1 0 dy
0 0 1 dz
0 0 0 1

R will look like:
r11 r12 r13 0
r21 r22 r23 0
r31 r32 r33 0
0 0 0 1

And S will look similar to T, but with negative
signs for dx dy dz. Something like that.

The order of operation is: SRT.P

dx dy and dz are simply the components of C.

Something like that. My brain is quite fried today,
so do not design an airplane before you try this
on paper first…

Thank you iznogoud

I have followed your steps on paper first and then tried it on m code but was unable to perform arbitarty rotations.

iam posting my code below , which performs arbitary rotations,

void CMask::arbitary_rotation(CNode *currNode,float angle)
CNode center;

center.x = (minNode.x +maxNode.x)/2;
center.y = (minNode.y +maxNode.y)/2;

currNode->x = (currNode->x * cos(DEGTORAD(angle))) + 
	          (currNode->y * sin(DEGTORAD(angle))) -
			  (center.x    * cos(DEGTORAD(angle))) -
			  (center.y    * sin(DEGTORAD(angle))) + center.x ;

currNode->y = - (currNode->x  * sin(DEGTORAD(angle))) +
	            (currNode->y  * cos(DEGTORAD(angle)))  +
			    (center.x     * sin(DEGTORAD(angle)))  -
			    (center.y     * cos(DEGTORAD(angle)))  + center.y ;

currNode->z = 0.0;



Plz let me correct in this function,

I have changed the fomulae in different ways,
The current one gives be arbitary rotaitons but scales down to center…?

Advise me

Kumar, make life easy on yourself: learn matrices.

The whole enchilada:

Quick review:

Thanks SG, thanks for your help, i have solved this issue long before, any ways thanks for your replies i made 2 silly mistakes,first one is when i rotate the code for this and the second one is not for not posting here when i have trigged the error…


Is there anything like rotating points or vectors about a “Point” ?

I thought rotation is always specified with respect to some axis. Correct me if I am wrong!


Hi Dimensions,

There are lot of possible ways for rotating the object

  1. Rotate the object locally along any coordinate axis.(like earth rotates around itself with the center of rotation as the center
    of earth)

  2. Rotate the object locally in an arbitary vector direction.

  3. Rotate the object with respect to a point as center.along coordinate axis
    (like earth rotates around the sun).

  4. Rotate the object with respect to a point along vector direction “x,y,z”

  5. we can combine 1+3 or 2+3 or 1+4 or 2+4

I hope you might have understood the complexity of rotations by now.


Hi Kumar,

In all the cases you mentioned, the earth rotating about itself etc… You are always specifying rotation about some “axis (vector not point)”.

Point is a “locaiton” in 3D space. To specify rotations with respect to it you have to establish an ortho normal basis at that point and then specify your rotations with respect to those ortho normal basis vectors. (You are either generating or transforming the coordinate system but not specifying rotations with respect to a point).

I hope you understand the terminology better.