# Center of rotation Question

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

## 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:

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 on other sites

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 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 on other sites
Ahh, see it. Looks like he packed three vectors into a 3x3 matrix, and is computing three dot products, storing each dot product into a vector3.

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013607
×