RealDocs

UKismetMathLibrary::Divide_Vector2DVector2D

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

Description

Performs element-wise division of two 2D vectors, returning {A.X/B.X, A.Y/B.Y}. Useful for normalizing a coordinate by separate per-axis extents.

Caveats & Gotchas

  • Division by zero (either component of B being zero) will result in inf or NaN — there is no guard inside this function. Always verify B's components are non-zero before calling.
  • The engine will log a script error and return a safe value in Blueprint if a divide-by-zero occurs via ReportError_Divide_Vector2DVector2D, but C++ callers get no such safety net.

Signature

static UE_INL_API FVector2D Divide_Vector2DVector2D(FVector2D A, FVector2D B);

Parameters

Name Type Description Default
A FVector2D The dividend vector.
B FVector2D The divisor vector.

Return Type

FVector2D

Example

Normalize a screen position to [0,1] UV range C++
FVector2D PixelPos(800.f, 450.f);
FVector2D Resolution(1920.f, 1080.f);
FVector2D UV = UKismetMathLibrary::Divide_Vector2DVector2D(PixelPos, Resolution);
// UV = (0.416, 0.416)

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.