「Java月亮运动」java月亮围绕地球

博主:adminadmin 2023-01-04 20:21:12 1290

本篇文章给大家谈谈Java月亮运动,以及java月亮围绕地球对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

月亮的运动规律?

和其他天体一样,月球也处于永恒的运动之中。随着月球每天在星空中自西向东移动一大段距离,它的形状也在不断地变化着,这就是月亮位相变化,叫做月相。 (1)、当月球运行到地球和太阳之间,被太阳照亮的半球背着地球,我们看不见月亮,叫做"新月",也叫"朔",这是农历初一。 (2)、过了新月,月亮被照亮的部分逐渐转向地球,我们看到一钩弯月,称为"娥眉月",这时是农历初三、初四。 (3)、初七、初八看到的是半个月亮(凸边向西),叫做"上弦月"。 (4)、到了农历十五、十六、十七,月亮上亮的一面全部对着地球,我们能看到一轮圆月,称为"满月",也叫"望"。 (5)、满月过后,月亮的亮面逐渐变小,到农历二十二、二十三,又能看到半个月亮(凸边向东),叫做"下弦月"。下弦月半夜时分才能从东方升起。 (6)、再过一个星期,月亮又回到"朔"。 月相就是这样周而复始地变化着。如果用月相变化的周期计算,从新月到下一个新月,就是一个"朔望月",为29.53天左右。中国农历的一个月长度,就是根据"朔望月"确定的。 阴历朔的时候,月亮运行到地球和太阳之间,这时有可能发生日食。望的时候,地球处于月球和太阳之间,这是有可能发生月食。 由于月球每月绕地球公转一周,地球、月球、太阳之间的角度不断变化;我们把它叫做一个朔望月。一个连续新月的出现需要29.5天(709小时),随月球轨道周期(由恒星测量)因地球同时绕太阳公转变化而变化。 其中的规律你应该知道了吧!

java中,画一个月亮,最初在左下方,先慢慢沿45°上升,到顶时再慢慢沿45°下降到右下方。

public void draw(Graphics2D g) {

g.setColor(color);//设置颜色

g.setStroke(stroke);//宽度

int x, y, w, h;

if (startX endX) {//以下的startx 、endx都是由鼠标拖 动事件得到

x = endX;

w = startX - endX;

} else {

x = startX;

w = endX - startX;

}

if (startY endY) {

y = endY;

h = startY - endY;

} else {

y = startY;

h = endY - startY;

}

g.drawOval(x, y, w, h);

}

求求,JAVA一题: 在APPLET中画月亮,用HTML实现。

//在Applet中画月亮。

import java.awt.*;

import java.applet.Applet;

public class MoonApplet extends Applet

{

public void paint(Graphics g) //在Applet上绘图

{

g.setColor(Color.red);

g.drawString("The Moon",100,20);

int x=0,y=0; //圆外切矩形左上角坐标

x = this.getWidth() /4;

y = this.getHeight() /4;

int diameter = Math.min(this.getWidth()/2, this.getHeight()/2); //圆的直径

g.setColor(Color.yellow);

g.fillOval(x,y,diameter,diameter); //画圆

g.setColor(this.getBackground()); //设置为背景色

g.fillOval(x-20,y-20,diameter,diameter); //画圆

}

}

//这个也可以,但没用HTML实现

// 画月亮。

import java.awt.Color;

import java.awt.FlowLayout;

import java.awt.Graphics;

import java.awt.event.ComponentListener;

import java.awt.event.ComponentEvent;

import javax.swing.JFrame;

/*

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

*/

public class MoonJFrame extends JFrame implements ComponentListener

{

public MoonJFrame()

{

super("Moon");

this.setSize(400,300);

this.setVisible(true);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

}

public void paint(Graphics g) //在JFrame上作图

{

int x=0,y=0; //圆外切矩形左上角坐标

x = this.getWidth() /4;

y = this.getHeight() /4;

int diameter = Math.min(this.getWidth()/2, this.getHeight()/2); //圆的直径

g.setColor(Color.yellow);

g.fillOval(x,y,diameter,diameter); //画圆

g.setColor(this.getBackground()); //设置为窗口背景色

g.fillOval(x-20,y-20,diameter,diameter); //画圆

}

public void componentResized(ComponentEvent e) //改变窗口大小时

{

repaint(); //重画

}

public void componentMoved(ComponentEvent e) { }

public void componentHidden(ComponentEvent e) { }

public void componentShown(ComponentEvent e) { }

public static void main(String arg[])

{

new MoonJFrame();

}

}

可以的 ~

记得结帖

Java编写月亮程序

给你写了个简单的测试,基本能实现你所描述的

package com.bobo.thread;

import java.awt.*;

import javax.swing.*;

public class Test extends JFrame implements Runnable {

static int i = 10;

static int j = 440;

public Test() {

this.setSize(500, 500);

this.setVisible(true);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public void paint(Graphics g) {

super.paint(g);

g.setColor(Color.BLACK);

g.fillRect(0, 0, 500, 500);

g.setColor(Color.white);

g.fillOval(i, j, 60, 60);

g.setColor(Color.BLACK);

g.fillOval(i - 20, j - 20, 60, 60);

}

public void run() {

while (true) {

try {

Thread.sleep(500);

} catch (InterruptedException e) {

e.printStackTrace();

}

if (i = 155) {

i += 5;

j += 15;

}

if (i 155) {

i += 5;

j -= 15;

}

if (i = 305) {

i = 10;

j = 440;

}

System.out.println(i + " " + j);

this.repaint();

}

}

public static void main(String args[]) {

new Thread(new Test()).start();

}

}

画一个月亮,使月亮整体移动,先升起在落下。用java编写

推荐一个方法,你试试,首先先用java的Graphics类画一个月亮,然后使用Graphics2D的translate(int dx, int dy)的方法,参数是新点的坐标,然后在新的位置重新画月亮

在一个月中,月球在天空怎样移动

现在以太阳为参照物,月亮可以近似的认为在黄道上自西向东运动.每29.5306天绕黄道一圈.

再考虑上太阳做得天体周日运动,天体周日运动的方向是自东向西,一天转动一周.

两者综合起来考虑就是月亮运动的规律.

关于Java月亮运动和java月亮围绕地球的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。