You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Matt Juntunen <ma...@hotmail.com> on 2018/06/05 03:06:03 UTC

[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: https://issues.apache.org/jira/projects/GEOMETRY/issues/GEOMETRY-7.

Thanks,
Matt



Re: [geometry] Polar/Spherical Coordinates API

Posted by Matt Juntunen <ma...@hotmail.com>.
I picked those particular names since they seemed to be the most consistent across all of the references I looked at. I'll be sure that they're documented in the pull request.

-Matt

________________________________
From: Gilles <gi...@harfang.homelinux.org>
Sent: Monday, June 25, 2018 8:20:03 AM
To: dev@commons.apache.org
Subject: Re: [geometry] Polar/Spherical Coordinates API

Hi.

On Sun, 24 Jun 2018 18:44:47 +0000, Matt Juntunen wrote:
> Hello,
>
>
> I didn't receive any feedback on this so I'm going to assume that
> everyone is okay with this approach.

More likely, nobody had a look. :-}

> I'm working on a pull request now
>
> (https://github.com/darkma773r/commons-geometry/tree/polar-spherical-working).
> Also, I'm changing the property names of the existing
> SphericalCoordinates class from "r", "theta", and "phi" to "radius",
> "azimuth", and "polar" since there are competing conventions for the
> meanings of "theta" and "phi" and the latter set of property names is
> unambiguous and far more intuitive. Likewise, the properties for the
> PolarCoordinates class are "radius" and "azimuth" (there was no prior
> version of this class).

Personally, I don't think one or the other is more intuitive;
it's more a question of habit, but most importantly, it should
be documented and, if possible, the names should follow the
convention used in the reference (most often links to Wikipedia,
or Mathworld).

Best regards,
Gilles

>
>
> Thanks,
>
> Matt
>
>
> ________________________________
> From: Matt Juntunen <ma...@hotmail.com>
> Sent: Monday, June 4, 2018 11:06 PM
> To: Commons Developers List
> Subject: [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:
> https://issues.apache.org/jira/projects/GEOMETRY/issues/GEOMETRY-7.
>
> Thanks,
> Matt


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [geometry] Polar/Spherical Coordinates API

Posted by Gilles <gi...@harfang.homelinux.org>.
Hi.

On Sun, 24 Jun 2018 18:44:47 +0000, Matt Juntunen wrote:
> Hello,
>
>
> I didn't receive any feedback on this so I'm going to assume that
> everyone is okay with this approach.

More likely, nobody had a look. :-}

> I'm working on a pull request now
> 
> (https://github.com/darkma773r/commons-geometry/tree/polar-spherical-working).
> Also, I'm changing the property names of the existing
> SphericalCoordinates class from "r", "theta", and "phi" to "radius",
> "azimuth", and "polar" since there are competing conventions for the
> meanings of "theta" and "phi" and the latter set of property names is
> unambiguous and far more intuitive. Likewise, the properties for the
> PolarCoordinates class are "radius" and "azimuth" (there was no prior
> version of this class).

Personally, I don't think one or the other is more intuitive;
it's more a question of habit, but most importantly, it should
be documented and, if possible, the names should follow the
convention used in the reference (most often links to Wikipedia,
or Mathworld).

Best regards,
Gilles

>
>
> Thanks,
>
> Matt
>
>
> ________________________________
> From: Matt Juntunen <ma...@hotmail.com>
> Sent: Monday, June 4, 2018 11:06 PM
> To: Commons Developers List
> Subject: [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:
> https://issues.apache.org/jira/projects/GEOMETRY/issues/GEOMETRY-7.
>
> Thanks,
> Matt


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [geometry] Polar/Spherical Coordinates API

Posted by Matt Juntunen <ma...@hotmail.com>.
Hello,


I didn't receive any feedback on this so I'm going to assume that everyone is okay with this approach. I'm working on a pull request now (https://github.com/darkma773r/commons-geometry/tree/polar-spherical-working). Also, I'm changing the property names of the existing SphericalCoordinates class from "r", "theta", and "phi" to "radius", "azimuth", and "polar" since there are competing conventions for the meanings of "theta" and "phi" and the latter set of property names is unambiguous and far more intuitive. Likewise, the properties for the PolarCoordinates class are "radius" and "azimuth" (there was no prior version of this class).


Thanks,

Matt


________________________________
From: Matt Juntunen <ma...@hotmail.com>
Sent: Monday, June 4, 2018 11:06 PM
To: Commons Developers List
Subject: [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: https://issues.apache.org/jira/projects/GEOMETRY/issues/GEOMETRY-7.

Thanks,
Matt