Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong result from createBasisTransform #62

Open
renoelmendorp opened this issue Aug 22, 2018 · 2 comments
Open

Wrong result from createBasisTransform #62

renoelmendorp opened this issue Aug 22, 2018 · 2 comments
Assignees

Comments

@renoelmendorp
Copy link

renoelmendorp commented Aug 22, 2018

I noticed some weird behaviour in createBasisTransform (see code below).
When calculating the transform from a plane with a Z-normal to an Y-normal, I get the wrong affine transform. Is this normal behaviour?
I'm using Matlab R2017b.

p1 = createPlane([0 0 0],[0 0 1]);

% create points in XY plane
pnts1 = [-1 -1 0;
          1 -1 0;
          1  1 0;
         -1  1 0];
     
drawPoint3d(pnts1);
drawPlane3d(p1);
% --> points are all in the XY plane

% create YZ plane (X-normal)
p2 = createPlane([0 0 0],[1 0 0]);

% transform points
t2 = createBasisTransform3d(p1,p2);
pnts2 = transformPoint3d(pnts1,t2);
% --> points are all in the YZ plane

hold on
drawPoint3d(pnts2);
drawPlane3d(p2);
hold off

% create XZ plane (Y-normal)
p3 = createPlane([0 0 0],[0 1 0]);

% transform points
t3 = createBasisTransform3d(p1,p3);
pnts3 = transformPoint3d(pnts1,t3);
% --> for some reason points are still in the YZ plane

hold on
drawPoint3d(pnts3);
drawPlane3d(p3);
hold off
@dlegland dlegland self-assigned this Aug 29, 2018
@dlegland
Copy link
Member

Hi,

I was away from computer for a while. I will check it ASAP.
Best
David

@dlegland
Copy link
Member

dlegland commented Sep 6, 2018

Hi again,

after having a look, I believe this is the normal behaviour.
After applying transform "t3", the coordinates of the points "pnts3" are expressed in terms of direction vectors of the plane p3. The four points are in the (global) XY plane. The plane p3 has first direction vector as [0 0 -1]. Therefore, the four points have their first coordinate in the basis of plane p3 equal to a constant (here equal to zero). Then, they all lie in a plane that corresponds to a YZ plane.

You can use the following to project back to "reference" basis:

t3g =  createBasisTransform3d(p3, 'global');
pnts3g = transformPoint3d(pnts3, t3g);
drawPoint3d(pnts3g, 'g*');

Best,
David

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants