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

Dual of 1 returns false #170

Open
deanrobertcook opened this issue May 2, 2024 · 0 comments
Open

Dual of 1 returns false #170

deanrobertcook opened this issue May 2, 2024 · 0 comments

Comments

@deanrobertcook
Copy link

Hi, thanks first off for this impressive library. It's been a joy playing around with it so far.

I found the gluLookAt example recently on observable and wanted to try it out on the actual camera used in a 3DPGA setup. I copied over the align function:

var align = (p,q)=>{
  for (var i=0, M=1, P=!1, Q=!1; i<p.length; ++i) {
    P = Q & (M >>> p[i]);
    Q = Q & q[i];
    M = (1 + Q.Normalized / P.Normalized).Normalized * M;
  }
  return M
}

But noticed I was getting NaNs in the output multivectors. After digging around a bit, I realised that !1 returns false, so P and Q aren't initialized to the pseudoscalar, as expected.

The line in question seems to be:

static Dual(a) { if (typeof a=='boolean' || typeof a=='number') return !a; return Element.toEl(a).Dual; };

So returning false seems to be the intended behaviour.

For now, I found a workaround by just using Element.toEl(1).Dual directly, but I wanted to raise this issue in case anyone else bumps into it. I'm not sure if it's possible to remove the typeof a =='number' check without unintended consequences, but it would be nice to have a consistent dual operation for 1, especially if we shouldn't use the pseudoscalar directly if it's degenerate?

Thanks in advance!

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

1 participant