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/24 19:09:38 UTC

[geometry] Additional Euclidean Point/Vector Methods

Hi all,


I'd like to add some additional methods to the Euclidean Point/Vector classes. Some are for convenience/readability and some are critical pieces of functionality that I believe are missing.



Vector Methods:

  1.  length() - Return the length of the vector; this is a more intuitive and easier to read alias for getNorm().
  2.  withLength(double len) - Return a new vector with the same direction as the current one but with the given length. This is equivalent  to "vec.normalize().scalarMultiply(len);" but without the intermediate vector.
  3.  project(Vector?D v) - Return a new vector representing the result of projecting the current vector onto the given vector.
  4.  reject(Vector?D v) - Return a new vector with all components in the direction of v "rejected". This can also be pictured as returning a new vector representing the result of projecting the current vector onto the plane with the given normal. This operation is the complement of the project() function since "vec.project(n).add(vec.reject(n))" equals the original vector.
  5.  lerp(double t, Vector?D v) - Perform a linear interpolation between the current vector and the given vector. If t == 0, a vector equal to the current vector is returned. If t == 1, a vector equal to the given vector is returned. All other values are interpolated linearly. For example, t == 0.5 would give the halfway point between the two vectors. There should also be a static version of this method.



Point Methods:

  1.  lerp(double t, Point?D p) - Same as the vector lerp() method but for points. There should also be a static version available.



Thoughts? Comments? I've opened up a JIRA issue for this as well: https://issues.apache.org/jira/projects/GEOMETRY/issues/GEOMETRY-9



Thanks,

Matt


Re: [geometry] Additional Euclidean Point/Vector Methods

Posted by Matt Juntunen <ma...@hotmail.com>.
Thanks, Gilles. "magnitude" sounds good. We'd then have "getMagnitude()" and "withMagnitude(double mag)".

-Matt

________________________________
From: Gilles <gi...@harfang.homelinux.org>
Sent: Monday, June 25, 2018 8:27:29 AM
To: dev@commons.apache.org
Subject: Re: [geometry] Additional Euclidean Point/Vector Methods

On Sun, 24 Jun 2018 19:09:38 +0000, Matt Juntunen wrote:
> Hi all,
>
>
> I'd like to add some additional methods to the Euclidean Point/Vector
> classes. Some are for convenience/readability and some are critical
> pieces of functionality that I believe are missing.
>
>
>
> Vector Methods:
>
>   1.  length() - Return the length of the vector; this is a more
> intuitive and easier to read alias for getNorm().

"length" has a different usage in Java.
"magnitude" would more readily convey the intended meaning.
But "norm" is shorter, and as clear IMHO.

I've no issue with the other proposals.

Best,
Gilles

>   2.  withLength(double len) - Return a new vector with the same
> direction as the current one but with the given length. This is
> equivalent  to "vec.normalize().scalarMultiply(len);" but without the
> intermediate vector.
>   3.  project(Vector?D v) - Return a new vector representing the
> result of projecting the current vector onto the given vector.
>   4.  reject(Vector?D v) - Return a new vector with all components in
> the direction of v "rejected". This can also be pictured as returning
> a new vector representing the result of projecting the current vector
> onto the plane with the given normal. This operation is the
> complement
> of the project() function since "vec.project(n).add(vec.reject(n))"
> equals the original vector.
>   5.  lerp(double t, Vector?D v) - Perform a linear interpolation
> between the current vector and the given vector. If t == 0, a vector
> equal to the current vector is returned. If t == 1, a vector equal to
> the given vector is returned. All other values are interpolated
> linearly. For example, t == 0.5 would give the halfway point between
> the two vectors. There should also be a static version of this
> method.
>
>
>
> Point Methods:
>
>   1.  lerp(double t, Point?D p) - Same as the vector lerp() method
> but for points. There should also be a static version available.
>
>
>
> Thoughts? Comments? I've opened up a JIRA issue for this as well:
> https://issues.apache.org/jira/projects/GEOMETRY/issues/GEOMETRY-9
>
>
>
> Thanks,
>
> Matt


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


Re: [geometry] Additional Euclidean Point/Vector Methods

Posted by Gilles <gi...@harfang.homelinux.org>.
On Sun, 24 Jun 2018 19:09:38 +0000, Matt Juntunen wrote:
> Hi all,
>
>
> I'd like to add some additional methods to the Euclidean Point/Vector
> classes. Some are for convenience/readability and some are critical
> pieces of functionality that I believe are missing.
>
>
>
> Vector Methods:
>
>   1.  length() - Return the length of the vector; this is a more
> intuitive and easier to read alias for getNorm().

"length" has a different usage in Java.
"magnitude" would more readily convey the intended meaning.
But "norm" is shorter, and as clear IMHO.

I've no issue with the other proposals.

Best,
Gilles

>   2.  withLength(double len) - Return a new vector with the same
> direction as the current one but with the given length. This is
> equivalent  to "vec.normalize().scalarMultiply(len);" but without the
> intermediate vector.
>   3.  project(Vector?D v) - Return a new vector representing the
> result of projecting the current vector onto the given vector.
>   4.  reject(Vector?D v) - Return a new vector with all components in
> the direction of v "rejected". This can also be pictured as returning
> a new vector representing the result of projecting the current vector
> onto the plane with the given normal. This operation is the 
> complement
> of the project() function since "vec.project(n).add(vec.reject(n))"
> equals the original vector.
>   5.  lerp(double t, Vector?D v) - Perform a linear interpolation
> between the current vector and the given vector. If t == 0, a vector
> equal to the current vector is returned. If t == 1, a vector equal to
> the given vector is returned. All other values are interpolated
> linearly. For example, t == 0.5 would give the halfway point between
> the two vectors. There should also be a static version of this 
> method.
>
>
>
> Point Methods:
>
>   1.  lerp(double t, Point?D p) - Same as the vector lerp() method
> but for points. There should also be a static version available.
>
>
>
> Thoughts? Comments? I've opened up a JIRA issue for this as well:
> https://issues.apache.org/jira/projects/GEOMETRY/issues/GEOMETRY-9
>
>
>
> Thanks,
>
> Matt


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