Open PavielKraskouski opened 2 months ago
Tagging subscribers to this area: @dotnet/area-system-numerics See info in area-owners.md if you want to be subscribed.
Wouldn't this be more intuitive if it was an extension on Vector
instead of a pure static
method?
public static class VectorProjectionExtensions
{
public static Vector3 ProjectOnto(this Vector3 point, Plane plane)
Vector3 point = new(1, 2, 3);
Plane plane = new(Vector3.UnitY, -5);
Vector3 projectedPoint = point.ProjectOnto(plane);
In this case, it is better to make this method static for Vector3
, similar to Vector3.Transform
methods.
namespace System.Numerics;
public struct Vector3
{
public static Vector3 Project(Vector3 point, Plane plane);
}
In this case, it is better to make this method static for
Vector3
, similar toVector3.Transform
methods.
@PavielKraskouski can you elaborate why it is better? Are you arguing just for consistency with Vector3.Transform
, or is there more to it?
I think the extension method approach not only makes this more intuitive to use, but also more discoverable.
I do agree that Vector3.Project
seems more intuitive than Plane.Project
though as the latter gives the impression you are "projecting the plane", which is not really what is happening.
@julealgon My main argument is that .Net doesn't have a separate extension method class for vectors, so I think creating a class with one method is impractical. However, if .Net developers approve this method, they'll decide where to add it.
Background and motivation
Projecting a point onto a plane is a basic operation that can be used in a variety of problems.
API Proposal
API Usage
Alternative Designs
No response
Risks
No response