真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

曲線飛行軌道java代碼 曲線飛行軌道java代碼是什么

跪求大神榮光 回答下面的機(jī)器人的JAVA代碼

import java.text.DecimalFormat;

10余年建站經(jīng)驗(yàn), 成都網(wǎng)站建設(shè)、成都網(wǎng)站制作客戶的見證與正確選擇。創(chuàng)新互聯(lián)公司提供完善的營(yíng)銷型網(wǎng)頁建站明細(xì)報(bào)價(jià)表。后期開發(fā)更加便捷高效,我們致力于追求更美、更快、更規(guī)范。

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

public class WalkDistance {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

int n = in.nextInt();

for (int i = 0; i n; i++) {

String order = in.next();

System.out.println(new DecimalFormat("0.00").format(calDistance(order)));

}

in.close();

}

private static float calDistance(String order) {

char[] orderChar = order.toCharArray();

ListString orderList = new ArrayListString();

int num = 0;

for (int i = 0, len = orderChar.length; i len; i++) {

if (orderChar[i] = '0' orderChar[i] = '9') {

num++;

} else {

if (num == 0) {

orderList.add(String.valueOf(orderChar[i]));

} else {

StringBuffer sb = new StringBuffer();

for (int j = num; j 0; j--) {

sb.append(String.valueOf(orderChar[i - j]));

}

orderList.add(sb.toString());

orderList.add(String.valueOf(orderChar[i]));

num = 0;

}

}

if (i == len - 1 num != 0) {

StringBuffer sb = new StringBuffer();

for (int j = num - 1; j = 0; j--) {

sb.append(String.valueOf(orderChar[i - j]));

}

orderList.add(sb.toString());

}

}

Point curPoint = new Point(0, 0, 90);

for (int i = 0, len = orderList.size(); i len; i++) {

if ("R".equals(orderList.get(i))) {

curPoint.angle = (curPoint.angle - 90 + 360) % 360;

} else if ("L".equals(orderList.get(i))) {

curPoint.angle = (curPoint.angle + 90) % 360;

} else {

curPoint.setLocation(curPoint, orderList.get(i));

}

}

return curPoint.getDis();

}

static class Point {

private int x;

private int y;

private int angle;

private float dis;

public Point(int x, int y, int angle) {

this.x = x;

this.y = y;

this.angle = angle;

this.dis = (float) 0;

}

public void setLocation(Point point, String distance) {

if (point.angle == 0) {

point.x += Integer.valueOf(distance);

} else if (point.angle == 90) {

point.y += Integer.valueOf(distance);

} else if (point.angle == 180) {

point.x -= Integer.valueOf(distance);

} else {

point.y -= Integer.valueOf(distance);

}

}

public float getDis() {

return (float) Math.sqrt(this.x * this.x + this.y * this.y);

}

}

}

java怎樣繪制螺旋曲線

用極坐標(biāo)方程,一個(gè)點(diǎn)一個(gè)點(diǎn)的畫。給你段我以前寫的程序,雖然不是螺旋曲線,但也差不多。import java.awt.*;

import javax.swing.*;public class Spirograph extends JApplet {

public static void main(String s[]) {

JFrame frame = new JFrame();

frame.setTitle("Spirograph");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JApplet applet = new Spirograph();

applet.init();

frame.getContentPane().add(applet);

frame.pack();

frame.setVisible(true);

}

public void init() {

JPanel panel = new SpiroPanel();

getContentPane().add(panel);

}

}class SpiroPanel extends JPanel{

int nPoints = 1000;

double r1 = 60;

double r2 = 50;

double p = 70;

public SpiroPanel() {

setPreferredSize(new Dimension(400, 400));

setBackground(Color.white);

} public void paintComponent(Graphics g) {

super.paintComponent(g);

Graphics2D g2 = (Graphics2D)g;

g2.translate(200,200);

int x1=(int)(r1+r2-p);

int y1=0;

int x2;

int y2;

for (int i=0; inPoints; i++) {

double t = i*Math.PI/90;

x2 = (int)((r1+r2)*Math.cos(t)-p*Math.cos((r1+r2)*t/r2));

y2 = (int)((r1+r2)*Math.sin(t)-p*Math.sin((r1+r2)*t/r2));

g2.drawLine(x1, y1, x2, y2);

x1 = x2;

y1 = y2;

}

}

}

已知曲線的公式,如何用JAVA編程將曲線顯示出來,要JAVA源代碼

代碼如下,只是時(shí)間倉促有些簡(jiǎn)陋,沒有坐標(biāo)軸,而且大小比例問題也沒有調(diào)好。不過功能實(shí)現(xiàn)了。嘎嘎,新手上路,騰云駕霧。

import java.awt.Graphics;

import javax.swing.JFrame;

import javax.swing.JPanel;

public class Bbso extends JPanel{

int x,y,x1,y1,m=100;

double d;

public Bbso() {

JFrame f = new JFrame();

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

f.setBounds(100,100,500,300);

f.setTitle("畫曲線");

f.setVisible(true);

f.getContentPane().add(this);

}

public static void main(String arg[]) {

new Bbso();

}

public void paint(Graphics g) {

super.paintComponent(g);

x1=0;

y1=0;

for(x=-250;x250;x++) {

d=-0.2045*x*x+100.41*x-6736.8; //這里填寫公式

y=(int)d;

g.drawLine(x1,y1+m,x,y+m);

x1=x;

y1=y;

}

}

}


新聞名稱:曲線飛行軌道java代碼 曲線飛行軌道java代碼是什么
分享路徑:http://weahome.cn/article/doeojsh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部