#### Archived

This topic is now archived and is closed to further replies.

# Rotating points (plane)

This topic is 5409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I''ve got 3 vertices and I use them to create the plane. I would like to rotate the plane so I could detect collisions precisely. I don''t know how to start. Is there any easy way to rotate the plane ? I thought that I could multiply the plane''s normal by rotation matrix but it would be rotated around the origin (0,0,0), I guess ? So maybe should I multiply all points by rotation matrix ? But what should that matrix look like ? Like this (y rotation):? |cos(angle) 0 sin(angle) point1.x| | 0 1 0 point1.y| |-sin(angle) 0 cos(angle) point1.z| | 0 0 0 1 | I really don''t know how to do it Thanks in advance for any help.

##### Share on other sites
what do you want to rotate around?

##### Share on other sites
The center of the triangle which is made of those 3 vertices mentioned above.

##### Share on other sites
just rotate the normal, and keep using that point in the plane to calculate D in:

A x + B y + C z + D = 0

that should work.

Assuming your collision detection code uses planes as vec4s.

##### Share on other sites
*sigh*

stating what the plane equation is rarely helps anyone, try this:

let me explain what this does. given a point you want to rotate 'p', the angle you want to rotate it 'theta' and a line about which 'p' will rotate, RotPtByLn returns the new positon.

p1 should be the center of the triangle, p2 the normal + the center, and p is one of the verts. This should do the trick, but remember to always precalculate the normal and center to use during all three rotations because it will change as you move each vertex.

Tell me if this helps

EDIT: oh, V3F is just defined as "typedef D3DXVECTOR3 V3F;"

//-----------------------------------------------------------------------------// Name: RotPtByLn()// Desc: // Auth: http://astronomy.swin.edu.au/~pbourke/geometry/rotate///-----------------------------------------------------------------------------V3F RotPtByLn( V3F p, float theta, V3F p1, V3F p2 ){    D3DXVECTOR3 u, q1, q2;    float d;    q1.x = p.x - p1.x;    q1.y = p.y - p1.y;    q1.z = p.z - p1.z;    u.x = p2.x - p1.x;    u.y = p2.y - p1.y;    u.z = p2.z - p1.z;    u /= sqrtf( u.x * u.x + u.y * u.y + u.z * u.z );    d = sqrtf( u.y * u.y + u.z * u.z );    float temp = d;    if( temp < 0 ) temp = -temp;    if( temp > 0.000001 )    {        q2.x = q1.x;        q2.y = q1.y * u.z / d - q1.z * u.y / d;        q2.z = q1.y * u.y / d + q1.z * u.z / d;    }    else    {        q2 = q1;    }    q1.x = q2.x * d - q2.z * u.x;    q1.y = q2.y;    q1.z = q2.x * u.x + q2.z * d;    q2.x = q1.x * cosf( theta ) - q1.y * sinf( theta );    q2.y = q1.x * sinf( theta ) + q1.y * cosf( theta );    q2.z = q1.z;    q1.x =   q2.x * d + q2.z * u.x;    q1.y =   q2.y;    q1.z = - q2.x * u.x + q2.z * d;    temp = d;    if( temp < 0 ) temp = -temp;    if( temp > 0.000001 )    {        q2.x =   q1.x;        q2.y =   q1.y * u.z / d + q1.z * u.y / d;        q2.z = - q1.y * u.y / d + q1.z * u.z / d;    }    else    {        q2 = q1;    }    q1.x = q2.x + p1.x;    q1.y = q2.y + p1.y;    q1.z = q2.z + p1.z;    return q1;}

[edited by - Mulligan on February 27, 2004 12:23:08 PM]

##### Share on other sites

Mulligan:

In my case isn't it esasier to calculate the new normal and distance than to multiply all 3 points and then create the plane?

I'm rather new at all this staff and I'm just worried that your approach is out of my league at this moment

Regards.

[edited by - BigMac on February 27, 2004 2:47:55 PM]

##### Share on other sites
well, i probably dont full understand what youre doing i guess. What are you trying to accomplish? Some background info would do.

##### Share on other sites
I''ve got a bounding box consisted of 3 planes. I want them to rotate with the object so I could detect collisions more precisely.

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 9
• 12
• 16
• 26
• 10
• ### Forum Statistics

• Total Topics
633768
• Total Posts
3013753
×