Compare commits

..

No commits in common. "7408520819cd9e6e8e66371d2b5493608e75d151" and "d6a83b0f4bbb45455349ae7bdfb08740b0b95e7c" have entirely different histories.

4 changed files with 18 additions and 44 deletions

View file

@ -26,8 +26,7 @@ var ADDITIONAL_VARCHARS = [
"ₕ","ₖ","ₗ","ₘ","ₙ","ₚ","ₛ", "ₕ","ₖ","ₗ","ₘ","ₙ","ₚ","ₛ",
"ₜ","¹","²","³","⁴","⁵","⁶", "ₜ","¹","²","³","⁴","⁵","⁶",
"⁷","⁸","⁹","⁰","₁","₂","₃", "⁷","⁸","⁹","⁰","₁","₂","₃",
"₄","₅","₆","₇","₈","₉","₀", "₄","₅","₆","₇","₈","₉","₀"
"∞"
] ]
function Instruction(type, value) { function Instruction(type, value) {
@ -692,7 +691,7 @@ TokenStream.prototype.isConst = function () {
var i = startPos; var i = startPos;
for (; i < this.expression.length; i++) { for (; i < this.expression.length; i++) {
var c = this.expression.charAt(i); var c = this.expression.charAt(i);
if (c.toUpperCase() === c.toLowerCase() && !ADDITIONAL_VARCHARS.includes(c)) { if (c.toUpperCase() === c.toLowerCase()) {
if (i === this.pos || (c !== '_' && c !== '.' && (c < '0' || c > '9'))) { if (i === this.pos || (c !== '_' && c !== '.' && (c < '0' || c > '9'))) {
break; break;
} }

View file

@ -437,8 +437,8 @@ class UnionDomain extends Domain {
static import(frm) { static import(frm) {
var domains = frm.trim().split("") var domains = frm.trim().split("")
if(domains.length == 1) domains = frm.trim().split("U") // Fallback if(domains.length == 1) domains = frm.trim().split("U") // Fallback
var dom2 = parseDomain(domains.pop()) var dom1 = parseDomain(domains.pop())
var dom1 = parseDomain(domains.join('')) var dom2 = parseDomain(domains.join(''))
return dom1.union(dom2) return dom1.union(dom2)
} }
} }

View file

@ -114,7 +114,7 @@ function variable(vari, wrapIn$ = false) {
"ₜ","¹","²","³","⁴","⁵","⁶", "ₜ","¹","²","³","⁴","⁵","⁶",
"⁷","⁸","⁹","⁰","₁","₂","₃", "⁷","⁸","⁹","⁰","₁","₂","₃",
"₄","₅","₆","₇","₈","₉","₀", "₄","₅","₆","₇","₈","₉","₀",
"pi", "∞"] "pi"]
let equivalchars = ["\\alpha","\\beta","\\gamma","\\delta","\\epsilon","\\zeta","\\eta", let equivalchars = ["\\alpha","\\beta","\\gamma","\\delta","\\epsilon","\\zeta","\\eta",
"\\pi","\\theta","\\kappa","\\lambda","\\mu","\\xi","\\rho", "\\pi","\\theta","\\kappa","\\lambda","\\mu","\\xi","\\rho",
"\\sigma","\\sigma","\\tau","\\phi","\\chi","\\psi","\\omega", "\\sigma","\\sigma","\\tau","\\phi","\\chi","\\psi","\\omega",
@ -124,7 +124,7 @@ function variable(vari, wrapIn$ = false) {
"{}_{t}","{}^{1}","{}^{2}","{}^{3}","{}^{4}","{}^{5}","{}^{6}", "{}_{t}","{}^{1}","{}^{2}","{}^{3}","{}^{4}","{}^{5}","{}^{6}",
"{}^{7}","{}^{8}","{}^{9}","{}^{0}","{}_{1}","{}_{2}","{}_{3}", "{}^{7}","{}^{8}","{}^{9}","{}^{0}","{}_{1}","{}_{2}","{}_{3}",
"{}_{4}","{}_{5}","{}_{6}","{}_{7}","{}_{8}","{}_{9}","{}_{0}", "{}_{4}","{}_{5}","{}_{6}","{}_{7}","{}_{8}","{}_{9}","{}_{0}",
"\\pi", "\\infty"] "\\pi"]
if(wrapIn$) if(wrapIn$)
for(let i = 0; i < unicodechars.length; i++) { for(let i = 0; i < unicodechars.length; i++) {
if(vari.includes(unicodechars[i])) if(vari.includes(unicodechars[i]))

View file

@ -115,9 +115,9 @@ class Function extends Common.ExecutableObject {
static drawFunction(canvas, ctx, expr, definitionDomain, destinationDomain, drawPoints = true, drawDash = true) { static drawFunction(canvas, ctx, expr, definitionDomain, destinationDomain, drawPoints = true, drawDash = true) {
// Reusable in other objects. // Reusable in other objects.
// Drawing small traits every 0.2px // Drawing small traits every 0.2px
var pxprecision = 10 var pxprecision = 1
var previousX = canvas.px2x(0) var previousX = canvas.px2x(0)
var previousY = null; var previousY;
if(definitionDomain instanceof MathLib.SpecialDomain && definitionDomain.moveSupported) { if(definitionDomain instanceof MathLib.SpecialDomain && definitionDomain.moveSupported) {
// Point based functions. // Point based functions.
previousX = definitionDomain.next(previousX) previousX = definitionDomain.next(previousX)
@ -147,42 +147,17 @@ class Function extends Common.ExecutableObject {
ctx.fillRect(canvas.x2px(previousX)-1, canvas.y2px(previousY)-5, 2, 10) ctx.fillRect(canvas.x2px(previousX)-1, canvas.y2px(previousY)-5, 2, 10)
} }
} else { } else {
if(definitionDomain.includes(previousX)) previousY = expr.execute(previousX)
// PreviousY at the start of the canvas for(var px = pxprecision; px < canvas.canvasSize.width; px += pxprecision) {
previousY = expr.execute(previousX) var currentX = canvas.px2x(px)
for(let px = pxprecision; px < canvas.canvasSize.width; px += pxprecision) { var currentY = expr.execute(currentX)
let currentX = canvas.px2x(px) if((definitionDomain.includes(currentX) || definitionDomain.includes(previousX)) &&
if(!definitionDomain.includes(previousX) && definitionDomain.includes(currentX)) { (destinationDomain.includes(currentY) || destinationDomain.includes(previousY)) &&
// Should draw up to currentX, but NOT at previousX. Math.abs(previousY-currentY)<100) {
// Need to find the starting point. canvas.drawLine(ctx, canvas.x2px(previousX), canvas.y2px(previousY), canvas.x2px(currentX), canvas.y2px(currentY))
let tmpPx = px-pxprecision
do {
tmpPx++;
previousX = canvas.px2x(tmpPx)
} while(!definitionDomain.includes(previousX))
// Recaclulate previousY
previousY = expr.execute(previousX)
} else if(!definitionDomain.includes(currentX)) {
// Next x is NOT in the definition domain.
// Augmenting the pixel precision until this condition is fulfilled.
let tmpPx = px
do {
tmpPx--;
currentX = canvas.px2x(tmpPx)
} while(!definitionDomain.includes(currentX) && currentX != previousX)
}
if(definitionDomain.includes(previousX) && definitionDomain.includes(currentX)) {
let currentY = expr.execute(currentX)
if(destinationDomain.includes(currentY)) {
if(previousY != null && destinationDomain.includes(previousY)) {
canvas.drawLine(ctx, canvas.x2px(previousX), canvas.y2px(previousY), canvas.x2px(currentX), canvas.y2px(currentY))
}
} }
previousY = currentY previousX = currentX
} else { previousY = currentY
previousY = null // Last y was invalid, so let's not draw anything from it.
}
previousX = canvas.px2x(px)
} }
} }
} }