#### Archived

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

# D3DXTransformNormal/Coord

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

## Recommended Posts

What do they do? These don''t give the same result: (Matrix is similar to D3DXMATRIX)
  Vector3 Vector3TransformCoord(const Vector3& v,const Matrix& m) { return Vector3( v.x * m._11 + v.y * m._21 + v.z * m._31 + m._41, v.x * m._12 + v.y * m._22 + v.z * m._32 + m._42, v.x * m._13 + v.y * m._23 + v.z * m._33 + m._43 ); } Vector3 Vector3TransformNormal(const Vector3& v,const Matrix& m) { return Vector3( v.x * m._11 + v.y * m._21 + v.z * m._31, v.x * m._12 + v.y * m._22 + v.z * m._32, v.x * m._13 + v.y * m._23 + v.z * m._33 ); } 
Thanks for help.

##### Share on other sites
The first one, TransformCoord, transforms the vertex INCLUDING the translation that is stored in _41, _42, _43.

The latter on, TransformNormal, does not consider the translation what makes sense since just the direction of a normal is required.

##### Share on other sites
Oops, I was not clear enough. Of course these two give different result.

But the point is that I don''t get the same result when using my Vector3TransformCoord/Normal instead of corresponding D3DX ones.

Why???

##### Share on other sites
From what I see of your code it should be the same. But you use your own classes and many other things can be wrong with it. DX returns the (mathematically correct but mostly useless) D3DXVECTOR4 when multiplying a vector with a 4x4 matrix which can directly be casted to D3DXVECTOR3.

Your solution will be slower than the DX one since you create a new Vector3 object (this will call the constructor and hence allocate space for your complete Vector class etc), so why not make use of the tested DX library. If you dont you anyway have some overhead with converting your vectors/matrices to the DX ones as they are needed for DX commands that you will use.

On the other hand you learn alot more if you build your own classes, this experience is worth the additional costs since it raises your market value

- thomas

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633325
• Total Posts
3011370
• ### Who's Online (See full list)

There are no registered users currently online

×