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

Electric Field: Change the color of the arrows depending on the force applied to them. #1

Open
xlikesasukee opened this issue Jul 7, 2023 · 0 comments

Comments

@xlikesasukee
Copy link
Owner

I would like the color of the Arrows to change depending on the value of F you get for them.
This could happen inside this function.

function drawElectricField() {
  for (let x = 0; x < 1200; x += 40) {
    for (let y = 0; y < 1200; y += 40) {
      let base = new Complex(x, y);
      let F = calculateElectricFieldVector(base).mul(1e15);

      //getColor(F) get corresponding color out of F value

      let absF = F.abs();
      F = F.mul(1/absF);
      drawArrow(base, new Complex(base.re + F.re, base.im + F.im),[35, 144, 145]);
    }
  }
}

The color variable is already a parameter of my drawArrow funciton.

@xlikesasukee xlikesasukee changed the title Electric Field: Change the Color of the Arrows depending on Force applied to them. Electric Field: Change the color of the arrows depending on the force applied to them. Jul 7, 2023
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