RealDocs

UKismetMathLibrary::Matrix_TransformVector4

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticBlueprintPure

Description

Transforms a homogeneous FVector4 by the full 4x4 matrix. The W component of the input vector participates in the multiply, so translation is applied only when W=1.

Caveats & Gotchas

  • Setting V.W = 0 transforms a direction vector (translation is ignored); setting V.W = 1 transforms a position. Mixing up W values is a common source of incorrect translation application.
  • The result is an untransformed FVector4 — no perspective divide is performed. For projection matrices you must divide XYZ by the resulting W yourself.

Signature

static UE_INL_API FVector4 Matrix_TransformVector4(const FMatrix& M, FVector4 V)

Parameters

Name Type Description Default
M const FMatrix& The matrix to transform with.
V FVector4 The homogeneous 4D vector to transform.

Return Type

FVector4

Example

Transform a homogeneous position through a projection matrix C++
FVector4 ClipSpacePos = UKismetMathLibrary::Matrix_TransformVector4(ProjectionMatrix, FVector4(WorldPos, 1.0f));
// Perspective divide to get NDC
FVector NDC(ClipSpacePos.X / ClipSpacePos.W, ClipSpacePos.Y / ClipSpacePos.W, ClipSpacePos.Z / ClipSpacePos.W);

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.