Ejemplo n.º 1
0
 def newVelocityCheck(self, rux, ruy, newAngle):
     print("new velocity check")
     print("ux" + str(self.ux))
     print("uy" + str(self.uy))
     print("u Angle:" + str(AngleMath.toDeg(self.uAngle)))
     print("ramp angle:" + str(AngleMath.toDeg(self.ramp.angle)))
     print("u:" + str(self.u))
     print("rux:" + str(rux))
     print("ruy:" + str(ruy))
     Ru = math.sqrt(rux * rux + ruy * ruy)
     print("Ru:" + str(Ru))
     print("new angle:" + str(AngleMath.toDeg(newAngle)))
Ejemplo n.º 2
0
    def bestAngle1(acc, step):
        myAngle = 0
        while True:

            myDer = derivative(Learn.xofangle, myAngle, dx=1e-3)
            # print("Derivative Value: " + str(myDer))
            lf = 1
            if (abs(lf * myDer) < step / 10):
                lf = step / 10 / myDer

            myAngle += lf * myDer
            print("CURRENT ANGLE:" + str(AngleMath.toDeg(myAngle)))

            if abs(myDer) < acc:
                break

        print("Best angle derivative method is:" +
              str(AngleMath.toDeg(myAngle)))
Ejemplo n.º 3
0
 def calc_uxy0_info(self):
     print("calc uxy0:")
     print("angle:" + str(AngleMath.toDeg(self.angle)))
     print("x0:" + str(self.x0))
     print("y0:" + str(self.y0))
     print("ramp height:" + str(self.ramp.current0))
     print("ux0:" + str(self.ux0))
     print("uy0:" + str(self.uy0))
     U = math.sqrt(self.ux0 * self.ux0 + self.uy0 * self.uy0)
     print("U:" + str(U))
def drawRamp(myRamp, myHeight, myWidth):
    border_pen = turtle.Turtle()
    border_pen.speed(0)
    border_pen.color("black")
    border_pen.penup()

    border_pen.setposition(-myWidth / 2, myRamp.height - myHeight / 2)
    border_pen.pendown()
    border_pen.pensize(7)
    border_pen.rt(AngleMath.toDeg(myRamp.angle))
    border_pen.fd(myRamp.length)
    border_pen.hideturtle()
def drawProjectile(player, myProjectile, myHeight, myWidth):
    player.shape("circle")
    player.shapesize(0.65, 0.65)
    player.penup()
    player.speed(0)
    myProjectile.calc_xy0()
    player.setposition(-myWidth / 2, myProjectile.ramp.height - myHeight / 2)
    player.color("black")
    player.pendown()
    player.pensize(7)
    player.lt(90 - AngleMath.toDeg(myProjectile.ramp.angle))
    player.fd(myProjectile.height)
    player.pensize(4)
    player.color("yellow")
Ejemplo n.º 6
0
    def bestAngle2(acc):
        angle = 0.0
        angleRate = 0.1
        myDir = 1

        while (angleRate > acc):

            if (Learn.xofangle(angle + angleRate) > Learn.xofangle(angle)):

                angle += angleRate
                prevDir = 1
            elif (Learn.xofangle(angle - angleRate) > Learn.xofangle(angle)):

                angle -= angleRate
                prevDir = -1
            else:
                angleRate = angleRate / 2

            if (myDir * prevDir < 0):
                angleRate = (angleRate) / 2
                angleRate = abs(angleRate)
            print("CURRENT ANGLE:" + str(AngleMath.toDeg(angle)))

        print("Best angle numerical method:" + str(AngleMath.toDeg(angle)))
Ejemplo n.º 7
0
from ramp import Ramp
from target import Target
from angleMath import AngleMath
from projectile import Projectile
from learn import Learn
import math
from scipy.misc import derivative
import graphics
from myConstants import myConstants

myRamp = Ramp(700, AngleMath.toRad(15))
myProjectile = Projectile(60, AngleMath.toRad(20), 100, myRamp)

graphics.initialGraphics(myProjectile)
print("initial x0:" + str(myProjectile.x0))
print("initial y0:" + str(myProjectile.y0))
myRamp.printStats()

myProjectile.calcxtFall(0.000001)

t = 0.0
# for i in range(1, len(myProjectile.tFallList)):

for i in range(0, len(myProjectile.tList)):

    if (myProjectile.tList[i] >= t):
        myProjectile.x = myProjectile.xList[i]
        myProjectile.y = myProjectile.yList[i]

        graphics.move(graphics.player, myProjectile, t)
        t += myConstants.myRate
Ejemplo n.º 8
0
 def print_u(self, t):
     self.calc_u(t)
     print("t=" + str(t))
     print("u=" + str(self.u) + " at an angle " +
           str(AngleMath.toDeg(self.uAngle)))