I have a node with the following verts:
-3 4 0
-2 5 0
1 -2 0
Now I want to rotate the node around the z-axis at 0 0 clockwise by 45 degrees.
Is there somebody who can tell me how to calculate the new position of the verts? This seems to be somewhat above my payment class …
And yes, I could use the orientation statement to do that, but that is not the question.
Do you mean x =-320, y=-250 and z=
(or maybe z= 120 )? Otherwise I don’t understand. Also, is your z fixed and you want the other 2 points to rotate about it? -120
FWIW, you may find the information contained in my
TR’s Other Shapes package useful, especially the script library numbered 2 in the description on the project page.
The verts i’ve given will form a triangle as shown in blue. If I rotate it by 45 degrees clockwise, then the result should be a figure as shown in red. Actually you can think of rotating points in a two-dimensional space since z is always 0 in the example.
In that case here is the formula for 2d rotation in a clockwise direction.
SinNegAngle = Sin(-Angle)
CosNegAngle = Cos(-Angle)
New_X = Old_X * CosNegAngle - Old_Y * SinNegAngle
New_Y = Old_X * SinNegAngle + Old_Y * CosNegAngle
The angle is in degrees. To rotate in an anti-clockwise direction you would use just the angle and not the negative version of it. Warning - the above formula is the standard 2d rotation and might not produce the result you are expecting. That is because the rotation is about the 2d origin (i.e. 0, 0). Anyway, give that a try.
Since you’re using a matrix representation, I suppose the rotation matrix
cos(a) -sin(a) 0
sin(a) cos(a) 0
0 0 1
is what you’re looking for.
The new “node” should then be
-3cos(a)+4sin(a) -3*[-sin(a)]+4cos(a) 0
-2cos(a)+5sin(a) -2*[-sin(a)]+5cos(a) 0
1 cos(a)-2sin(a) +1[-sin(a)]-2cos(a) 0
with a=pi/4, cos(a)=sin(a)=0.707, this gives
0.707 4.95 0
2.121 4.95 0
-0.707 -2.12 0
@Tarot_Redhand: Thanks, but seemingly it doesn’t work. I will check out 4760’s approach after lunch …
Thanks for answering. Your values are nearly the same as the ones I got independently with Tarots formula (see above).
Still something is wrong.
My new triangle is distorted and it doesn’t look like just 45°, the rotation seems to be larger. I wonder what is wrong, since the formula seems to be correct
Instead of risking overheating of my brain I’d just “paint” the triangle in Gmax, rotate it and see where it ends up.
Looking at the drawing above, I’d say everything’s correct. You have a picture of the new triangle? I wonder what’s going on there too!
For a better view so we can see what is going on you need to provide an image with both triangles fully closed so each actually has 3 sides.
Yes, gaining knowledge could be braindamaging.
Letting GMax or any other software doing it for me won’t help me to understand.
Well, to complete the triangle you need just to connect the first and last point.
For me it looks as if the inner angles of the red and blue triangle are not equal. I do not expect that the rotation changes these angles.
I include the excel, so you may have a look if you want.
Rotation.zip (2.4 KB)
I think the problema is the center you define for the rotation.
I would use one of the verts as a fixed rotation center.
Once you have reached the desired angle rotation you can displacer the whole 2d OBJECT in the x and y axis.
I confirm the rotation doesn’t change the angles or the lengths. However the scale difference between the abscissa and the ordinate does!
Here’s how the triangles show with an orthonormal system:
With the original values:
I buy it. The formula is correct. Excel does much to display the triangles distorted. One must closely watch out that the scale of x and y-axis is identical.
Thanks for your help.