-1

How do I determine the homogeneous transformation matrix for the following question:

A triangle with vertices A(50,20),B(40,10),C(60,10) is required to be rotated by 45 degrees in clockwise direction about line y = -4x - 3. Find out the final coordinate positions of the triangle after performing the desired transformation.

I only found the steps or formula for reflection about line y=mx+c, but I didn't find any solution to compute the transformation matrix for the above question.

pppery
  • 3,731
  • 22
  • 33
  • 46
P_99
  • 9
  • 5
  • It's easy to find formula for a rotation matrix given a specific axis passing through origin. Then you just need to move the triangle so that the rotation point passes through the origin, rotate, then move back into place. – HolyBlackCat Aug 28 '23 at 13:54

2 Answers2

0

Partial answer is on StackExchange, "How rotate a point around an arbitrary line in 3D?"

Link to StackExchange answered question: https://robotics.stackexchange.com/questions/12782/how-rotate-a-point-around-an-arbitrary-line-in-3d

First part: You make A, B, C into 3D vectors, z = 0:

A_3d = (50, 20, 0)
B_3d = (40, 10, 0)
C_3d = (60, 10, 0)

The above you need to do since rotating 45 degrees over a line is a 3D thing and needs a Z coordinate.

You will get a 3D triangle back, likely not in Z = 0. You'll need to construct a vector/matrix with (X, Y, Z, 1) for each point you are rotating.

Part 2, do the steps in the StackExchange answer. This is your vector space matrix.

0
  1. use unit direction vector of your line as Z axis

    however your y=mx+c is 2D equation of line however in 3D your:

    y = -4x - 3
    

    becomes:

    4*x - 1*y +0*z +3 = 0
    

    which represents plane !!! So how is your line really defined? I would expect some parametric vector form based on line endpoints p0,p1:

    p(t) = p0 + (p1-p0)*t
    

    where p1-p0 is the direction vector...

    the same goes for your triangle the points are 2D ...

    in case your input is 2D you can convert it to 3D by setting z coordinate to 0 so (by using x=0,x=1):

    p0 = (0 , -3 , 0)
    p1 = (1 , -7 , 0)
    Z = (p1-p0) = (1,4,0)
    

    and:

    A = (50,20,0)
    B = (40,10,0)
    C = (60,10,0) 
    
  2. compute 2 perpendicular vectors X,Y to each and to Z

    so simply exploit cross product for example:

     Z /= length(Z)
     X = (1,0,0)
     if (abs(dot(X,Z))<1e-6) X = (0,1,0)
     Y = cross(X,Z)
     X = cross(Y,Z)
     X /= length(X)
     Y /= length(Y)
    
  3. construct matrix M

    simply feed the X,Y,Z vectors as basis vectors to rotational part of 4x4 homogenuous transform matrix and use any point belonging to your line as origin O (for example O=p0). Now you have transform matrix which Z axis is aligned to your line.

  4. transform your triangle

    so each point transform to M local coordinates, then rotate around Z by 45 deg and transform back to global coordinates... equation (order of operands) might differ depending on used notation for example:

    p' = M*Rotate_around_Z(45 deg)*Inverse(M)*p 
    

    where M*Rotate_around_Z(45 deg)*Inverse(M) can be multiplied together to single transform matrix...

    the CW/CCW of rotation in 2D is simple however in 3D you have to chose which side you are looking. In the equations above the direction is set by the order of line endpoints (p0,p1) or sign of direction vector so you have to have consistent input...

Spektre
  • 49,595
  • 11
  • 110
  • 380