git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[geometry] Euclidean Vector API


Hi all,

Gilles and I are stuck on a discussion of a few of the names in the API for the Euclidean vector classes (Vector1D, Vector2D, Vector3D) and I'd like to get some outside feedback. Our discussion has focused on ease of use, clarity, and mathematical accuracy. Below are a few of the options we've been discussing for class names and factory methods, in no particular order. I'm using Vector2D as an example here but the other classes would be similar. It would be very helpful if some of you could say which API you prefer and your reasoning behind it.

Note that each of the classes below would have getX(), getY(), and toPolar() methods (among many others). The toPolar() method returns an instance of a PolarCoordinates class.

a)
class Vector2D implements Vector {
    public static Vector2D ofCartesian(double x, double y);
    public static Vector2D ofPolar(double radius, double angle);
}

b)
class Vector2D implements Vector {
    public static Vector2D of(double x, double y);
    public static Vector2D fromPolar(double radius, double angle);
}

c)
class Cartesian3D implements Vector {
    public static Cartesian3D of(double x, double y);
    public static Cartesian3D ofPolar(double radius, double angle);
}

Thanks,
Matt J