Skip to content

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

@xlikesasukee

Description

@xlikesasukee

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions