[ 
https://issues.apache.org/jira/browse/GEOMETRY-163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Aryan Ganjoo updated GEOMETRY-163:
----------------------------------
    Description: 
Applying a shear with EmbeddingPlane.transform produces a non-orthogonal basis, 
so points on the plane no longer round-trip through toSubspace and toSpace. 
This transform is finite and invertible (determinant 1).

{code:java}
var precision = Precision.doubleEquivalenceOfEpsilon(1e-10);
var plane = Planes.fromPointAndPlaneVectors(
    Vector3D.ZERO, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, precision);
var shear = AffineTransformMatrix3D.of(
    1, 1, 0, 0,
    0, 1, 0, 0,
    0, 0, 1, 0);
var transformed = plane.transform(shear);
var point = Vector3D.of(1, 0, 0);
System.out.println(transformed.getU().dot(transformed.getV()));
System.out.println(transformed.toSpace(transformed.toSubspace(point)));
{code}

The dot product is about 0.7071 and the round-trip point is (1.5, 0.5, 0.0), 
rather than (1.0, 0.0, 0.0). Using plane.subspaceTransform(shear).getPlane() 
gives an orthogonal basis and the expected round trip.

Reproduced on master at 08664182d6c8f8a69da67f03c98e4c7bf6aa193b 
(1.1-SNAPSHOT). I am working on a fix with regression tests and plan to submit 
a PR. Please coordinate here before starting a parallel fix.

Report prepared with AI assistance.

  was:
Applying a shear with EmbeddingPlane.transform produces a non-orthogonal basis, 
so points on the plane no longer round-trip through toSubspace and toSpace. 
This transform is finite and invertible (determinant 1).

{code:java}
var precision = Precision.doubleEquivalenceOfEpsilon(1e-10);
var plane = Planes.fromPointAndPlaneVectors(
    Vector3D.ZERO, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, precision);
var shear = AffineTransformMatrix3D.of(
    1, 1, 0, 0,
    0, 1, 0, 0,
    0, 0, 1, 0);
var transformed = plane.transform(shear);
var point = Vector3D.of(1, 0, 0);
System.out.println(transformed.getU().dot(transformed.getV()));
System.out.println(transformed.toSpace(transformed.toSubspace(point)));
{code}

The dot product is about 0.7071 and the round-trip point is (1.5, 0.5, 0.0), 
rather than (1.0, 0.0, 0.0). Using plane.subspaceTransform(shear).getPlane() 
gives an orthogonal basis and the expected round trip.

Reproduced on master at 08664182d6c8f8a69da67f03c98e4c7bf6aa193b 
(1.1-SNAPSHOT). Happy to contribute a fix and regression tests.


> EmbeddingPlane.transform loses orthogonality under shear
> --------------------------------------------------------
>
>                 Key: GEOMETRY-163
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-163
>             Project: Commons Geometry
>          Issue Type: Bug
>         Environment: Java 17, macOS arm64; Commons Geometry 1.1-SNAPSHOT at 
> 08664182d6c8f8a69da67f03c98e4c7bf6aa193b.
>            Reporter: Aryan Ganjoo
>            Priority: Major
>
> Applying a shear with EmbeddingPlane.transform produces a non-orthogonal 
> basis, so points on the plane no longer round-trip through toSubspace and 
> toSpace. This transform is finite and invertible (determinant 1).
> {code:java}
> var precision = Precision.doubleEquivalenceOfEpsilon(1e-10);
> var plane = Planes.fromPointAndPlaneVectors(
>     Vector3D.ZERO, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, precision);
> var shear = AffineTransformMatrix3D.of(
>     1, 1, 0, 0,
>     0, 1, 0, 0,
>     0, 0, 1, 0);
> var transformed = plane.transform(shear);
> var point = Vector3D.of(1, 0, 0);
> System.out.println(transformed.getU().dot(transformed.getV()));
> System.out.println(transformed.toSpace(transformed.toSubspace(point)));
> {code}
> The dot product is about 0.7071 and the round-trip point is (1.5, 0.5, 0.0), 
> rather than (1.0, 0.0, 0.0). Using plane.subspaceTransform(shear).getPlane() 
> gives an orthogonal basis and the expected round trip.
> Reproduced on master at 08664182d6c8f8a69da67f03c98e4c7bf6aa193b 
> (1.1-SNAPSHOT). I am working on a fix with regression tests and plan to 
> submit a PR. Please coordinate here before starting a parallel fix.
> Report prepared with AI assistance.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to