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

[geometry] Polar/Spherical Coordinates API

Hi all,

I'm trying to add support for polar and spherical coordinates to the Euclidean geometry code. My basic idea is to add them as simple DTOs with getters and factory methods in the Point?D and Vector?D classes. For example:

Polar polar = Polar.of(1, Math.PI / 2);
polar.getRadius(); // 1
polar.getTheta(); // 2

Vector2D vec = Vector2D.ofPolar(polar);
// also possible: Vector2D.ofPolar(1, Math.PI / 2)

// do stuff with vec; uses Cartesian coordinates internally

Polar result = vec.getPolar();

The Spherical class would be similar. Any thoughts, comments, or objections to this approach? I've create the following issue to track this: