• 13
• 27
• 9
• 9
• 20

# Trigonometry question

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

## Recommended Posts

If i had a 3D arrow model pointing upwards (0, 1, 0) and i set this:
 D3DXMATRIX world, rot; D3DXMatrixIdentity(&world); D3DXMatrixRotationAxis(&rot, &D3DXVECTOR3(1.0f, 0.0f, 0.0f), 0.3f); world = rot * world; ... 

How can i obtain new direction arrow is pointing?

##### Share on other sites
make a new vector and use the translate function.

##### Share on other sites
I don't see how's that gonna help? I need to obtain direction vector it is "pointing at" after rotation.

##### Share on other sites
Make a vector pointing (0, 1, 0), i.e. the same direction as your arrow model, and rotate it in the same way. The rotated vector will give you the direction of the arrow model after rotation...

Putting it a different way, choose two vertices on your original arrow model, a vertex on the "bottom" of the arrow and a vertex of the "top" (the pointy end) of the arrow. These two points define a vector, which points in the arrow's direction. Once your model is rotated, find those two same vertices, they define another vector, which still represents the arrow's direction (obviously). The conclusion trivially follows...

##### Share on other sites
 D3DXMatrixRotationAxis(&rot, &D3DXVECTOR3(1.0f, 0.0f, 0.0f), 0.1f); D3DXVECTOR4 orgDir(0.0f, 1.0f, 0.0f, 0.0f); D3DXVECTOR4 outDir; D3DXVec4Transform(&outDir, &orgDir, &rot); 

Is this what you mean?

##### Share on other sites
Yes, although you want to use

D3DXMatrixRotationAxis(&rot, &D3DXVECTOR3(1.0f, 0.0f, 0.0f), 0.3f);

as the rotation matrix (says 0.1 in your last post but 0.3 in the first one)

##### Share on other sites
It was my mistake, It was a typo. Thanks for your help.

##### Share on other sites
Or, since you already know that your model was pointing along one of the coordinate system axes, you could just read out the second column of the world matrix. (Transformation) matrices aren't magic, they are just four vectors: right, up, forward, position. (depending on your handedness and as what you define your x,y,z axes).

##### Share on other sites
I don't see how that would be correct?
I tried it and its almost similar, apart that 'z' axis is negative if i extract it from second column of world.