UKismetMathLibrary::Matrix_InverseTransformVector
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Transforms a direction vector by the inverse of the matrix without applying translation. Converts a world-space direction into the local space of the matrix. The header notes that for normals with non-uniform scale you should use TransformByUsingAdjointT instead.
Caveats & Gotchas
- • This is not correct for transforming surface normals under non-uniform scaling. Normals must be transformed by the transpose of the inverse (adjoint), not the plain inverse. Use TransformByUsingAdjointT on FMatrix directly for that case.
- • Like Matrix_InverseTransformPosition, this recomputes the inverse every call. Cache the inverse matrix if transforming many vectors.
Signature
static UE_INL_API FVector Matrix_InverseTransformVector(const FMatrix& M, FVector V) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| M | const FMatrix& | The transform matrix to invert before applying. | — |
| V | FVector | The world-space direction vector to transform into local space. | — |
Return Type
FVector Example
Convert a world-space impact normal into local space C++
FMatrix WorldToLocal = Actor->GetActorTransform().ToMatrixWithScale();
// OK for direction vectors that aren't surface normals
FVector LocalDir = UKismetMathLibrary::Matrix_InverseTransformVector(WorldToLocal, HitResult.ImpactNormal); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?