Skip to content

Proposal to add a vector projection function #166

Open
@ackh

Description

@ackh

Sometimes I need to project a vector on another vector, as described here. It seems that DirectXMath does not offer a function to do this out of the box which is why I came up with the following implementation:

inline XMVECTOR ProjectVectorToVector(XMVECTOR v1, XMVECTOR v2)
{
  return XMVectorMultiply(XMVectorDivide(XMVector3Dot(v1, v2), XMVector3Dot(v2, v2)), v2);
}

Admittedly, such a function isn't hard to implement but to me, it seems like such a common geometric operation that I think it makes sense to add this to DirectXMath itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalsimplemathRelated to SimpleMath (see DirectX Tool Kit)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions