• Advertisement
Sign in to follow this  

Center of rotation Question

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

D3DXVECTOR3 cls = zs + R_min * dot(D3DXVECTOR3(cos(anglstart), 0, sin(anglstart)), rotY(-PI / 2));
 
D3DXVECTOR3 dot(D3DXVECTOR3 t1, D3DXMATRIX t2)
{
    

    // x = ax + by + cz
    // y = px + qy + rz
    // z = ux + vy + wz

    double x = t1.x * t2._11 + t1.y * t2._21 + t1.z * t2._31;
    double y = t1.x * t2._12 + t1.y * t2._22 + t1.z * t2._32;
    double z = t1.x * t2._13 + t1.y * t2._23 + t1.z * t2._33;

    //double x = t1.x * t2._11 + t1.y * t2._12 + t1.z * t2._13;
    //double y = t1.x * t2._21 + t1.y * t2._22 + t1.z * t2._23;
    //double z = t1.x * t2._31 + t1.y * t2._32 + t1.z * t2._33;
    
    return D3DXVECTOR3(x, y, z);
}
 
D3DXMATRIX rotY(float angle)
{
    D3DXMATRIX rY;
    D3DXMatrixIdentity(&rY);
    D3DXMatrixRotationY(&rY, angle);
    return rY;
}
 

 

Input parameters:

angle start: 0 rad

start pos: 0, 0, 0

 

I assume the first vector calculaton is correct

D3DXVECTOR3(cos(anglstart), 0, sin(anglstart))

which ends up with 1, 0, 0

If the agent is turning left, I expand that vector in the south direction, which should end up with

something in the +ve x range, why in the end of the calculations, the x is negative,

 

I also assume the dot product is correct. The way it works is dotting the row vector against each column vector in

the matrix?

 

So what went wrong?

Thanks

Jack

 

Share this post


Link to post
Share on other sites
Advertisement

D3DXVECTOR3 dot(D3DXVECTOR3 t1, D3DXMATRIX t2) ...  The way it works is dotting the row vector against each column vector in the matrix?
 

 

Not generally, no.

 

A dot product takes two vectors of the same dimensions and gives a single number as the result result. For a three dimensional value it is: (a.x*b.x + a.y*b.y + a.z*b.z)

 

A cross product takes two vectors of the same dimensions and gives a single vectors as the result.  For a three dimensional value it is [ (a.y * b.z - a.z * b.y), (a.z * b.x - a.x * b.z), (a.x * b.y - a.y * b.x) ]

 

What you've got there is... I'm not really sure, it doesn't immediately ring a bell.

Share this post


Link to post
Share on other sites

What you've got there is... I'm not really sure, it doesn't immediately ring a bell.

 

it seems to be doing a linear combination of vector t1 with each row (column?) of matrix t2...

 

doesn't ring a bell offhand... eigenvector? lin combo of a spanning set? sad to say, i don't remember anything from linear - and i got an A in it too!  :P

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement