超简单日地月模型

这篇博客介绍了如何在Unity3D中创建一个简单的太阳、地球和月亮模型,讲解了World Space、Screen Space等坐标系概念,并探讨了单例模式和命名空间在项目中的应用。
摘要由CSDN通过智能技术生成

如何做一个简单的 太阳,地球,月亮的模型

这部分代码是比较简单的,只需要写一个cs挂载在一个空对象上就可以了。

using UnityEngine;
using System.Collections;

public class hw2_1 : MonoBehaviour {

    //关于创建的一些值
    GameObject Sun;
    GameObject Earth;
    GameObject Moon;
    float SunR = 8f; //太阳的半径
    float EarR = 9f;
    float SunSize = 3f; //太阳的大小
    float MoonSize = 0.5f;

    
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要绘制日地轨道模型,我们需要使用Python中的turtle库,以及一些基本的几何知识。以下是一个简单的示例代码: ```python import turtle import math # 设置画布和海龟 canvas = turtle.Screen() canvas.bgcolor("black") t = turtle.Turtle() t.speed(0) t.color("white") t.pensize(2) # 日地距离、地球半径和球半径 sun_distance = 300 earth_radius = 50 moon_radius = 20 # 画日地轨道 t.penup() t.goto(-sun_distance, 0) t.pendown() t.circle(sun_distance) # 画地球轨道 t.penup() t.goto(0, 0) t.pendown() t.circle(sun_distance-100) # 计算地球和球的位置 earth_angle = 0 moon_angle = 0 while True: # 计算当前地球和球的位置 earth_x = (sun_distance-100) * math.cos(math.radians(earth_angle)) earth_y = (sun_distance-100) * math.sin(math.radians(earth_angle)) moon_x = earth_x + 100 * math.cos(math.radians(moon_angle)) moon_y = earth_y + 100 * math.sin(math.radians(moon_angle)) # 画地球和球 t.penup() t.goto(earth_x, earth_y) t.pendown() t.circle(earth_radius) t.penup() t.goto(moon_x, moon_y) t.pendown() t.circle(moon_radius) # 更新角度 earth_angle += 1 moon_angle += 12 # 等待一段间后清除画布 if earth_angle % 360 == 0: turtle.clear() # 隐藏海龟 t.hideturtle() # 等待点击关闭窗口 canvas.exitonclick() ``` 这个代码会画出一个日地轨道和一个地球轨道,并且会根据间不断更新地球和球的位置。你可以调整`sun_distance`、`earth_radius`和`moon_radius`变量来改变轨道和天体的大小。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值