Function directx_math::XMVector2Reflect[][src]

pub fn XMVector2Reflect(Incident: FXMVECTOR, Normal: FXMVECTOR) -> XMVECTOR

Reflects an incident 2D vector across a 2D normal vector.

Parameters

Incident 2D incident vector to reflect.

Normal 2D normal vector to reflect the incident vector across.

Return value

Returns the reflected incident angle.

Remarks

The following pseudocode demonstrates the operation of the function:

XMVECTOR Result;

float s = 2.0f * (Incident.x * Normal.x + Incident.y * Normal.y);    // 2.0 * dot(Incident, Normal);

Result.x = Incident.x - s * Normal.x;
Result.y = Incident.y - s * Normal.y;
Result.z = undefined;
Result.w = undefined;

return Result;

Reference

https://docs.microsoft.com/en-us/windows/win32/api/directxmath/nf-directxmath-XMVector2Reflect