# How to multiply a matrix by a point in directx 11 [closed]

Just like the title, how do I multiply a point by a matrix in directx 11

## closed as too broad by Gnemlock, Alexandre Vaillancourt♦, Engineer, Kromster, Tyyppi_77Jul 18 '17 at 12:26

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

You haven't specified if you are trying to do this on the CPU or on the GPU.

For GPU-based work, you do this in an HLSL shader. For example, from the Direct3D 11 tutorial #4:

VS_OUTPUT VS( float4 Pos : POSITION, float4 Color : COLOR )
{
VS_OUTPUT output = (VS_OUTPUT)0;
output.Pos = mul( Pos, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Color = Color;
return output;
}


If you are doing this on the CPU, it's important to understand that this isn't actually part of "DirectX 11". Instead, there are various utility libraries that can do this or you write your own. The recommended math library for DirectX development these days is DirectXMath which is included in the Windows 8.x SDK and the Windows 10 SDK.

With DirectXMath you use the XMVector2Transform, XMVector3Transform, or XMVector4Transform functions depending on your input vector.

using namespace DirectX;

XMVECTOR v1 = ...;
XMMATRIX m = ...;

XMVECTOR result = XMVector3Transform(v1, m);


You use basically the same functions in the older xnamath library that was in the legacy DirectX SDK, although you should move to using DirectXMath instead. You should avoid using the deprecated D3DXmath functions.

Since you are apparently new to DirectX 11 development, I recommend you take a look at the DirectX Tool Kit tutorials, and in particular take a look at the SimpleMath wrapper for DirectXMath.

Try passing your point into D3DXMatrixTranslation(), and your newly generated matrix will be fit for multiplication.