dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.47k stars 4.77k forks source link

[API Proposal]: Billboard Lefthanded APIs for System.Numerics.Matrix4x4 #93046

Open sqeezy opened 1 year ago

sqeezy commented 1 year ago

Background and motivation

Matrix4x4 recently added APIs for left handed creation of Matrix4x4. Replacing another matrix implementation led me to nice the billboard APIs did not get left handed equivalents. In order to not confuse people about which functions are actually expecting a right handed system, we should add left handed versions for the billboard APIs.

API Proposal

namespace System.Numerics;

public partial struct Matrix4x4
{
   public static Matrix4x4 CreateBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3 cameraForwardVector)
   public static Matrix4x4 CreateConstrainedBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 rotateAxis, Vector3 cameraForwardVector, Vector3 objectForwardVector)
}

API Usage

var billboardLeftHanded = Matrix4x4.CreateBillboardLeftHanded(objectPosition, cameraPosition, cameraUpVector, cameraForwardVector);
...
var billboardConstrainedLeftHanded = Matrix4x4.CreateConstrainedBillboardLeftHanded(objectPosition, cameraPosition, rotateAxis, cameraForwardVector, objectForwardVector);
ghost commented 1 year ago

Tagging subscribers to this area: @dotnet/area-system-numerics See info in area-owners.md if you want to be subscribed.

Issue Details
### Background and motivation Matrix4x4 recently added APIs for left handed creation of Matrix4x4. Replacing another matrix implementation led me to nice the billboard APIs did not get left handed equivalents. In order to not confuse people about which functions are actually expecting a right handed system, we should add left handed versions for the billboard APIs. ### API Proposal ```csharp namespace System.Numerics; public partial struct Matrix4x4 { public static Matrix4x4 CreateBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3 cameraForwardVector) public static Matrix4x4 CreateConstrainedBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 rotateAxis, Vector3 cameraForwardVector, Vector3 objectForwardVector) } ### API Usage ```csharp var billboardLeftHanded = CreateBillboardLeftHanded(objectPosition, cameraPosition, cameraUpVector, cameraForwardVector); ... var billboardConstrainedLeftHanded = CreateConstrainedBillboardLeftHanded(objectPosition, cameraPosition, rotateAxis, cameraForwardVector, objectForwardVector); } ### Alternative Designs _No response_ ### Risks _No response_
Author: sqeezy
Assignees: -
Labels: `api-suggestion`, `area-System.Numerics`, `untriaged`
Milestone: -
terrajobst commented 1 year ago

Video

namespace System.Numerics;

public partial struct Matrix4x4
{
   public static Matrix4x4 CreateBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3 cameraForwardVector);
   public static Matrix4x4 CreateConstrainedBillboardLeftHanded(Vector3 objectPosition, Vector3 cameraPosition, Vector3 rotateAxis, Vector3 cameraForwardVector, Vector3 objectForwardVector);
}