Skip to content

Commit

Permalink
Merge pull request #7 from kjvbrt/frac_q
Browse files Browse the repository at this point in the history
Printing fractional charges correctly
  • Loading branch information
kjvbrt authored Apr 9, 2024
2 parents 19dffb7 + aef5e97 commit 1794891
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion js/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,22 @@ export class InfoBox {
bottomLines.push("d = " + this.vertex + " mm");
bottomLines.push("t = " + this.time + " ns");
bottomLines.push("m = " + this.mass + " GeV");
bottomLines.push("q = " + this.charge + " e");
if (Math.abs(this.charge) < 1.0 && this.charge != 0) {
if (Math.round(this.charge * 1000) === 666) {
bottomLines.push("q = 2/3 e");
}
if (Math.round(this.charge * 1000) === -666) {
bottomLines.push("q = -2/3 e");
}
if (Math.round(this.charge * 1000) === 333) {
bottomLines.push("q = 1/3 e");
}
if (Math.round(this.charge * 1000) === -333) {
bottomLines.push("q = -1/3 e");
}
} else {
bottomLines.push("q = " + this.charge + " e");
}

ctx.save();
ctx.font = "16px sans-serif";
Expand Down

0 comments on commit 1794891

Please sign in to comment.