본문 바로가기
물리코딩

지구의 자전

by 로토마 2021. 6. 24.

물리코딩으로 구현한 지구의 자전

물리 코딩의 처음은 역시 우주다....

와우웅

glowscript에 기본으로 지구 텍스쳐가 있기 때문에 디자인은 구에 glowscript의 지구 텍스쳐를 입혀서 표현했다.

그리고 지구의 축과 반지름, 각속도를 설정하고,

while 문을 통해 시간의 흐름에 따라 지구가 자전하는 모습을 구현했다.

 

GlowScript 3.0 VPython

#Creating Earth
earth = sphere(radius = 6.4e6, texture = textures.earth) 
earth.rot_axis = vec(0,1,0)
earth.w = 2*pi/(24*60*60)*earth.rot_axis ## rad/s

#Scene Setting
scene.range = 10e6

#Time
t = 0
dt = 60

while t < 24*60*60:
    rate(1/dt*6000)
    
    #E-C-M integration
    earth.alpha = 0*earth.rot_axis
    earth.w = earth.w + earth.alpha*dt
    dtheta = mag(earth.w)*dt
    earth.rotate(angle=dtheta,axis=earth.rot_axis, origin=earth.pos)
    t = t + dt

 

https://www.glowscript.org/#/user/emilyjiminroh/folder/physicscoding/program/%EA%B0%95%EC%B2%B4%EC%9D%98%EC%9B%80%EC%A7%81%EC%9E%84

 

GlowScript IDE

GlowScript is an easy-to-use, powerful environment for creating 3D animations and publishing them on the web. Here at glowscript.org, you can write and run GlowScript programs right in your browser, store them in the cloud for free, and easily share them w

www.glowscript.org

 

'물리코딩' 카테고리의 다른 글

등속도, 등속직선, 등가속도 운동  (0) 2021.12.31
3체 운동  (0) 2021.07.07
수직(자유낙하운동) + 수평(포물선운동)  (0) 2021.06.28
달이 멈춘다면 ?!  (0) 2021.06.24
달의 공전  (0) 2021.06.24