Пример #1
0
  d_list=array(d_list)*scaling_factor

  return scipy.interpolate.interp1d(d_list,l_list)

ll=get_func_for_luminosity(r_planet=10,r_star=200,scaling_factor=1)
### begin for test ###



t=0
size = 0.025 
scene = display(title='Light curve', center = (0.52,0.58,0),width=400, height=450)

#ruler
ruler1 = ruler.ruler(vector(0, 0, 0), vector(1,0,0), unit = 0.1, length = 1.0, thickness = 0.01)
ruler2 = ruler.ruler(vector(0, 0, 0), vector(0,1,0), unit = 0.1, length = 1.1, thickness = 0.01)

#Setup for ball
dt = 0.001

#normal ball
ball = sphere(radius = size, color=color.white, make_trail=True) # ball 
ball.pos = vector( 0.0, 1.0, 0.0) # ball initial position
ball.orbit = curve(color=color.cyan, radius = 0.01)


#normal ball
while True:
    rate(100)
    tt=t%1
Пример #2
0
from visual import *
import ruler

g=9.8 # g = 9.8 m/s^2
size = 0.25 # ball radius = 0.25 m
mass = 10
scene = display(title='bouncing projectile', center = (0,5,0),width=1200, height=800, background=(0.5,0.5,0))
#floor = box(length=60, height=0.01, width=4, color=color.blue) # floor

#ruler
ruler1 = ruler.ruler(vector(-15, 0, 1), vector(1,0,0), unit = 2.0, length = 60.0, thickness = 0.2)
ruler2 = ruler.ruler(vector(-15, 0, 1), vector(0,1,0), unit = 1.0, length = 20.0, thickness = 0.2)

#common factor for both ball
v_initial = 10.0
theta_initial = 45.0*math.pi/180 #rad
dt = 0.001
drag_coef = 0.3
drag_power = 1.0

#normal ball
ball = sphere(radius = size, color=color.red, make_trail=True) # ball
ball.v = v_initial * vector(cos(theta_initial), sin(theta_initial), 0)
ball.pos = vector( -15.0, 0.0, 0.0) # ball initial position

#ball_1: ball with air drag
ball_1 = sphere(radius = size, color=color.green, make_trail=True)
ball_1.pos = vector( -15.0, 0.0, 0.0) # ball initial position
ball_1.v = v_initial * vector(cos(theta_initial), sin(theta_initial), 0)

Пример #3
0
def main():
    # initialize data
    m_data = data()

    # pygame initialization
    pygame.init()
    # font
    pygame.font.init()  # you have to call this at the start,
    # if you want to use this module.
    font12 = pygame.font.SysFont('Comic Sans MS', 12)
    font30 = pygame.font.SysFont('Comic Sans MS', 30)

    # configure window setings
    screen = pygame.display.set_mode((m_data.screenWidth, m_data.screenHeight))
    pygame.display.set_caption("Weather App")
    icon = pygame.image.load('res/icon.png')
    pygame.display.set_icon(icon)

    # initialize camera
    m_camera = camera()

    # initialize ruler
    m_ruler = ruler()

    # initialize weather data
    m_weatherGrid = weatherGrid(m_data)

    while m_data.running:
        # process events (input, etc.)
        mouseX, mouseY = pygame.mouse.get_pos()

        utilities.processInput(
            m_data,
            mouseX,
            mouseY,
            m_camera,
            m_ruler,
            m_weatherGrid,
        )

        # update camera position
        m_camera.posX = m_camera.posX + m_camera.deltaX * m_camera.deltaMultiplier
        m_camera.posY = m_camera.posY + m_camera.deltaY * m_camera.deltaMultiplier
        m_camera.boundaryCheck(m_data.mapWidth, m_data.mapHeight,
                               m_data.screenWidth, m_data.screenHeight)

        # fill screen
        screen.fill((0, 0, 0))

        # draw map
        screen.blit(m_data.mapSurfaceDraw,
                    (int(-m_camera.posX), int(-m_camera.posY)))

        # weather grid draw
        m_weatherGrid.draw(screen, m_data, m_camera)

        # draw ruler
        m_ruler.draw(screen, m_camera.posX, m_camera.posY, font30)

        # draw info block
        utilities.drawInfoBlock(screen, m_data, m_weatherGrid, font12)

        # show popup buttons
        utilities.popupButtons(screen, m_data, mouseX, mouseY, font12)

        # update screen
        pygame.display.update()

    m_data.shutdown
    m_weatherGrid.shutdown()
Пример #4
0
from visual import *
import ruler

g=9.8
size=0.25

scene=display(title='bouncing projectile',center=(0,5,0),width=1200,height=800,background=(0.5,0.5,0))
floor=box(length=30,height=0.01,width=4,color=color.blue)
ball=sphere(radius=size,color=color.red,make_tail=True)
ruler1=ruler.ruler(pos=vector(15,0,1),unit=2.0,length=30.0,thickness=0.2)
ruler2=ruler.ruler(pos=vector(-15,0,1),unit=1.0,length=10.0,thickness=0.2)

ball.pos=vector(-15.0,10.0,0.0)
ball.v=vector(2.0,0.0,0.0)
dt=0.001
while ball.pos.x<15.0:
	rate(1000)
	ball.pos+=ball.v*dt
	ball.v.y+=-g*dt
	if ball.v.y<=size and ball.v.y<0:
		ball.v.y=-ball.v.y
print 'end'
Пример #5
0
# ball.v = v_initial * vector(cos(theta_initial), sin(theta_initial), 0)
drag_coef = 0.3
drag_power = 1.0

size = 0.25  # ball radius = 0.25 m
m = 2.0
scene = display(title='bouncing projectile',
                center=(0, 5, 0),
                width=1200,
                height=800,
                background=(0.5, 0.5, 0))
floor = box(length=50, height=0.01, width=4, color=color.blue)  # floor
ball = sphere(radius=size, color=color.red, make_trail=True)  # ball
ruler1 = ruler.ruler(vector(-15, 0, 1),
                     vector(1, 0, 0),
                     unit=2.0,
                     length=40.0,
                     thickness=0.2)  # ruler1
ruler2 = ruler.ruler(vector(-15, 0, 1),
                     vector(0, 1, 0),
                     unit=1.0,
                     length=10.0,
                     thickness=0.2)  # ruler2
ball.pos = vector(-15.0, 0.0, 0.0)  # ball initial position
ball.v = v_initial * vector(cos(theta_initial), sin(theta_initial), 0)
dt = 0.001
magnitude = drag_coef * math.hypot(
    ball.v.x, ball.v.y
)**drag_power  # the drag force exerted on the projectile sets an acceleration with
# magnitude = drag_ coef * v ** drag_power and the acceleration