Exemplo n.º 1
0
def getValues(rpnStack, optionsObj):
    n = len(rpnStack)
    #Holds the current stack with which we solve for each x value. 
    #This is a progressive stack, in that all final values are held here along
    #with the intermediate results of the current value of x
    result = {
              "stack": [],
              "labels": []
              }

    

    for k in range(0, n):
        result["stack"].append([])
        a = optionsObj["start"] #starting value
        b = optionsObj["delta"] * 19 #ending value
        step = optionsObj["delta"] #increment value for the loop
        for d in properLoop(a, b, step):
            l = len(rpnStack[k])
            if (k == 0):
                result["labels"].append(a)
            for j in range(0, l):
                if (rpnStack[k][j].isdigit()):
                    result["stack"][k].append(rpnStack[k][j])
                #Catch the independent
                elif (independentVar.find(rpnStack[k][j]) >= 0):
                    result["stack"][k].append(a)
                #if the current token is an operator
                elif (operators.find(rpnStack[k][j]) >= 0):
                    one = float(result["stack"][k].pop())
                    two = float(result["stack"][k].pop())
                    if (rpnStack[k][j] == "+"):
                        result["stack"][k].append(two + one)
                    elif (rpnStack[k][j] == "-"):
                        result["stack"][k].append(two - one)
                    elif (rpnStack[k][j] == "*"):
                        result["stack"][k].append(two * one)
                    elif (rpnStack[k][j] == "/"):
                        result["stack"][k].append(two / one)
                    elif (rpnStack[k][j] == "^"):
                        result["stack"][k].append(math.pow(two, one))
                
                elif (rpnStack[k][j] in functionOperators):
                    one = float(result["stack"][k].pop())
                    if (rpnStack[k][j] == "sin"):
                        result["stack"][k].append(math.sin(one))
                    elif (rpnStack[k][j] == "cos"):
                        result["stack"][k].append(math.cos(one))
                    elif (rpnStack[k][j] == "tan"):
                        result["stack"][k].append(math.tan(one))
                    elif (rpnStack[k][j] == "arctan"):
                        result["stack"][k].append(math.atan(one))
                    elif (rpnStack[k][j] == "arcsin"):
                        result["stack"][k].append(math.asin(one))
                    if (rpnStack[k][j] == "arccos"):
                        result["stack"][k].append(math.acos(one))
            #Increment our value at the current points
            a += step
    #print("parser", stack)
    return result
Exemplo n.º 2
0
def getValues(rpnStack, optionsObj):
    n = len(rpnStack)
    #Holds the current stack with which we solve for each x value.
    #This is a progressive stack, in that all final values are held here along
    #with the intermediate results of the current value of x
    result = {"stack": [], "labels": []}

    for k in range(0, n):
        result["stack"].append([])
        a = optionsObj["start"]  #starting value
        b = optionsObj["delta"] * 19  #ending value
        step = optionsObj["delta"]  #increment value for the loop
        for d in properLoop(a, b, step):
            l = len(rpnStack[k])
            if (k == 0):
                result["labels"].append(a)
            for j in range(0, l):
                if (rpnStack[k][j].isdigit()):
                    result["stack"][k].append(rpnStack[k][j])
                #Catch the independent
                elif (independentVar.find(rpnStack[k][j]) >= 0):
                    result["stack"][k].append(a)
                #if the current token is an operator
                elif (operators.find(rpnStack[k][j]) >= 0):
                    one = float(result["stack"][k].pop())
                    two = float(result["stack"][k].pop())
                    if (rpnStack[k][j] == "+"):
                        result["stack"][k].append(two + one)
                    elif (rpnStack[k][j] == "-"):
                        result["stack"][k].append(two - one)
                    elif (rpnStack[k][j] == "*"):
                        result["stack"][k].append(two * one)
                    elif (rpnStack[k][j] == "/"):
                        result["stack"][k].append(two / one)
                    elif (rpnStack[k][j] == "^"):
                        result["stack"][k].append(math.pow(two, one))

                elif (rpnStack[k][j] in functionOperators):
                    one = float(result["stack"][k].pop())
                    if (rpnStack[k][j] == "sin"):
                        result["stack"][k].append(math.sin(one))
                    elif (rpnStack[k][j] == "cos"):
                        result["stack"][k].append(math.cos(one))
                    elif (rpnStack[k][j] == "tan"):
                        result["stack"][k].append(math.tan(one))
                    elif (rpnStack[k][j] == "arctan"):
                        result["stack"][k].append(math.atan(one))
                    elif (rpnStack[k][j] == "arcsin"):
                        result["stack"][k].append(math.asin(one))
                    if (rpnStack[k][j] == "arccos"):
                        result["stack"][k].append(math.acos(one))
            #Increment our value at the current points
            a += step
    #print("parser", stack)
    return result
Exemplo n.º 3
0
def getPlots(graphRange, RPNStack, resolution):
    n = len(RPNStack)
    #Holds the current stack with which we solve for each x value. 
    #This is a progressive stack, in that all final values are held here along
    #with the intermediate results of the current value of x
    stack = []
    

    for k in range(0, n):
        stack.append([])
        a = graphRange["xMin"] #starting value
        b = graphRange["xMax"] #ending value
        step = math.fabs(a - b) / resolution #increment value for the loop
        for d in properLoop(a, b, step):
            l = len(RPNStack[k])
            for j in range(0, l):
                if (RPNStack[k][j].isdigit()):
                    stack[k].append(RPNStack[k][j])
                #Catch the independent
                elif (independentVar.find(RPNStack[k][j]) >= 0):
                    stack[k].append(a)
                #if the current token is an operator
                elif (operators.find(RPNStack[k][j]) >= 0):
                    one = float(stack[k].pop())
                    two = float(stack[k].pop())
                    if (RPNStack[k][j] == "+"):
                        stack[k].append(two + one)
                    elif (RPNStack[k][j] == "-"):
                        stack[k].append(two - one)
                    elif (RPNStack[k][j] == "*"):
                        stack[k].append(two * one)
                    elif (RPNStack[k][j] == "/"):
                        stack[k].append(two / one)
                    elif (RPNStack[k][j] == "^"):
                        stack[k].append(math.pow(two, one))
                
                elif (RPNStack[k][j] in functionOperators):
                    one = float(stack[k].pop())
                    if (RPNStack[k][j] == "sin"):
                        stack[k].append(math.sin(one))
                    elif (RPNStack[k][j] == "cos"):
                        stack[k].append(math.cos(one))
                    elif (RPNStack[k][j] == "tan"):
                        stack[k].append(math.tan(one))
                    elif (RPNStack[k][j] == "arctan"):
                        stack[k].append(math.atan(one))
                    elif (RPNStack[k][j] == "arcsin"):
                        stack[k].append(math.asin(one))
                    if (RPNStack[k][j] == "arccos"):
                        stack[k].append(math.acos(one))
            #Increment our value at the current points
            a += step
    #print("parser", stack)
    return stack
Exemplo n.º 4
0
def getPlots(graphRange, RPNStack, resolution):
    n = len(RPNStack)
    #Holds the current stack with which we solve for each x value. 
    #This is a progressive stack, in that all final values are held here along
    #with the intermediate results of the current value of x
    stack = []
    

    for k in range(0, n):
        stack.append([])
        ax = graphRange["xMin"] #starting X value
        bx = graphRange["xMax"] #ending X value
        ay = graphRange["xMin"] #starting Y value
        by = graphRange["xMax"] #ending Y value
        stepx = math.fabs(ax - bx) / resolution #increment value in the X direction
        stepy = math.fabs(ay - by) / resolution #increment value in the Y direction
        i = 0
        for d in properLoop(ay, by, stepy):
            stack[k].append([])
            ax = graphRange["xMin"] #Reset these values for the next iteration
            bx = graphRange["xMax"] 
            for e in properLoop(ax, bx, stepx):
                l = len(RPNStack[k])
                for j in range(0, l):
                    if (RPNStack[k][j].isdigit()):
                        stack[k][i].append(RPNStack[k][j])
                    #Catch the independent
                    elif (independentVar.find(RPNStack[k][j]) >= 0):
                        if (RPNStack[k][j] == "x"):
                            stack[k][i].append(ax)
                        if (RPNStack[k][j] == "y"):
                            stack[k][i].append(ay)
                    #if the current token is an operator
                    elif (operators.find(RPNStack[k][j]) >= 0):
                        one = float(stack[k][i].pop())
                        two = float(stack[k][i].pop())
                        if (RPNStack[k][j] == "+"):
                            stack[k][i].append(two + one)
                        elif (RPNStack[k][j] == "-"):
                            stack[k][i].append(two - one)
                        elif (RPNStack[k][j] == "*"):
                            stack[k][i].append(two * one)
                        elif (RPNStack[k][j] == "/"):
                            stack[k][i].append(two / one)
                        elif (RPNStack[k][j] == "^"):
                            stack[k][i].append(math.pow(two, one))
                    
                    elif (RPNStack[k][j] in functionOperators):
                        one = float(stack[k][i].pop())
                        if (RPNStack[k][j] == "sin"):
                            stack[k][i].append(math.sin(one))
                        elif (RPNStack[k][j] == "cos"):
                            stack[k][i].append(math.cos(one))
                        elif (RPNStack[k][j] == "tan"):
                            stack[k][i].append(math.tan(one))
                        elif (RPNStack[k][j] == "arctan"):
                            stack[k][i].append(math.atan(one))
                        elif (RPNStack[k][j] == "arcsin"):
                            stack[k][i].append(math.asin(one))
                        if (RPNStack[k][j] == "arccos"):
                            stack[k][i].append(math.acos(one))
                #Increment our value at the current points
                ax += stepx
            ay += stepy
        i = i + 1
    #print("parser", stack)
    return stack
Exemplo n.º 5
0
def getPlots(graphRange, RPNStack, resolution):
    n = len(RPNStack)
    #Holds the current stack with which we solve for each x value.
    #This is a progressive stack, in that all final values are held here along
    #with the intermediate results of the current value of x
    stack = []

    for k in range(0, n):
        stack.append([])
        ax = graphRange["xMin"]  #starting X value
        bx = graphRange["xMax"]  #ending X value
        ay = graphRange["xMin"]  #starting Y value
        by = graphRange["xMax"]  #ending Y value
        stepx = math.fabs(ax -
                          bx) / resolution  #increment value in the X direction
        stepy = math.fabs(ay -
                          by) / resolution  #increment value in the Y direction
        i = 0
        for d in properLoop(ay, by, stepy):
            stack[k].append([])
            ax = graphRange["xMin"]  #Reset these values for the next iteration
            bx = graphRange["xMax"]
            for e in properLoop(ax, bx, stepx):
                l = len(RPNStack[k])
                for j in range(0, l):
                    if (RPNStack[k][j].isdigit()):
                        stack[k][i].append(RPNStack[k][j])
                    #Catch the independent
                    elif (independentVar.find(RPNStack[k][j]) >= 0):
                        if (RPNStack[k][j] == "x"):
                            stack[k][i].append(ax)
                        if (RPNStack[k][j] == "y"):
                            stack[k][i].append(ay)
                    #if the current token is an operator
                    elif (operators.find(RPNStack[k][j]) >= 0):
                        one = float(stack[k][i].pop())
                        two = float(stack[k][i].pop())
                        if (RPNStack[k][j] == "+"):
                            stack[k][i].append(two + one)
                        elif (RPNStack[k][j] == "-"):
                            stack[k][i].append(two - one)
                        elif (RPNStack[k][j] == "*"):
                            stack[k][i].append(two * one)
                        elif (RPNStack[k][j] == "/"):
                            stack[k][i].append(two / one)
                        elif (RPNStack[k][j] == "^"):
                            stack[k][i].append(math.pow(two, one))

                    elif (RPNStack[k][j] in functionOperators):
                        one = float(stack[k][i].pop())
                        if (RPNStack[k][j] == "sin"):
                            stack[k][i].append(math.sin(one))
                        elif (RPNStack[k][j] == "cos"):
                            stack[k][i].append(math.cos(one))
                        elif (RPNStack[k][j] == "tan"):
                            stack[k][i].append(math.tan(one))
                        elif (RPNStack[k][j] == "arctan"):
                            stack[k][i].append(math.atan(one))
                        elif (RPNStack[k][j] == "arcsin"):
                            stack[k][i].append(math.asin(one))
                        if (RPNStack[k][j] == "arccos"):
                            stack[k][i].append(math.acos(one))
                #Increment our value at the current points
                ax += stepx
            ay += stepy
        i = i + 1
    #print("parser", stack)
    return stack