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

"simple" vector field plot not displaying many points #164

Closed
sritchie opened this issue May 30, 2024 · 3 comments · Fixed by #165
Closed

"simple" vector field plot not displaying many points #164

sritchie opened this issue May 30, 2024 · 3 comments · Fixed by #165

Comments

@sritchie
Copy link
Contributor

Hi @stevenpetryk! I was playing around with some vector field examples, and noticed that some simple functions, like ([x, y]) => [x, y] or similar versions with [y, x], [y, -x] etc, all failed to fill in values in 3 quadrants:

image

Here's a stackblitz reproducing the problem:

https://stackblitz.com/edit/react-aqgdx6?file=src%2Findex.tsx

and the code:

import * as React from 'react';
import { createRoot } from 'react-dom/client';

import 'mafs/core.css';
import 'mafs/font.css';

import { Mafs, Plot, Coordinates, useMovablePoint } from 'mafs';

function VectorFieldExample() {
  return (
    <Mafs>
      <Coordinates.Cartesian subdivisions={2} />
      <Plot.VectorField
        xy={([x, y]) => [y, -x]}
        step={0.25}
        xyOpacity={([x, y]) => 0.5}
      />
    </Mafs>
  );
}

createRoot(document.getElementById('root')).render(<VectorFieldExample />);

If I change the step size to a non-multiple-of-0.25, like 0.25001, then 2 more quadrants appear but the top right is missing:

image

I don't see anything in the Stackblitz logs. Apologies if there is something obvious I'm not seeing in this example!

@stevenpetryk
Copy link
Owner

Looks like some NaNs are ending up inside the SVG path:

stevenpetryk added a commit that referenced this issue May 31, 2024
Closes #164.

`vec.normalize([0,0])` returns `[NaN, NaN]` (which is perhaps not great?
perhaps `vec.normalize`'s return value should be nullable or something).

Anyway, those NaNs were making their way into the SVG path, breaking it.
@stevenpetryk
Copy link
Owner

Fixed in v0.18.8.

@sritchie
Copy link
Contributor Author

sritchie commented Jun 1, 2024

Thanks @stevenpetryk !!

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

Successfully merging a pull request may close this issue.

2 participants