[性代][作] 旋矩@Morris' Blog|PChome Online 人新台
2012-12-30 13:57:12| 人3,107| 回0 | 上一篇 | 下一篇

[性代][作] 旋矩

0 收藏 0 0 站台

Linear Algebra: Programing Homework 2

2012/11/29

 

 

 

 

  目:定一三角形,其座:(-50,0)(0,0)(50,100),,依下列案例要求三角形做出相的向量旋算,出後的三角形座以及向量矩

 








LA2.png





 

 

加分件:若以形介面,三角形的化示出即可加10分。

 

  入:名input.txt的案,容:

                    旋的度

 

  出:名output.txt的案,容:

(1).    案例中指定的向量矩,每column之以TAB分隔,每row之以行符分隔。

(2).    後的,一 row 表示一座 ( x , y )

 

 

收件:12/20 24:00以前(未避免路壅塞,早上,不接受交

 

 

 

 

分明:

1.     一案例(下述案例)行正,60

 

2.     案例()行正,80

 

3.     三案例()行正,100

 

4.     避免因浮算造成的差,的算程中不出限小,四五入至小第二位。

若程中以分算表示果,助教斟酌加分。

抄者方以零分算。

 

案例    旋矩( (0,0) 支,旋30)< target="_blank" href="http://photo.pchome.com.tw/morris821028/135684687567">


 

入例

  名:input.txt

案容:

30

 

出例

  名:output.txt

案容:

Transform matrix:

 

cos(30)    -sin(30)

sin(30)    cos(30) 

 

The three coordinates:

 

( 0.00 , 0.00 )

( -93.30 , 61.60 )

( -6.70 , 111.60 )

 [程式作交方式]

 

上至FTP Server不接受交

 

IP:140.115.52.80

Port:21  &bsp;                                                    

UserPasswordlahomework9876543210

 

勿上含病毒之案。

FTP法使用寄信至 w29697146@gmail.com   王耀  

                       dennislinorz@gmail.com   林志浩    通知助教。

 

或是直接至A310室找助教

 

[上相定]

 

1.      所有程式案上至各作目。

2.      如程式行需特殊境或外明,一明文件加入後上。

3.      案命名如下

 

**_%%.zip 或 **_%%.rar

 

**:。

%%:作,有更新上就累加。

 

例:第一次作上至FTPHW02目下,名951234567_1.zip,後案有修改,上名951234567_2.zip,以此推,分以最新版本。

 

注意 : 本次作限使用C/C++ JAVA

 

各位同配合,以利分登。

有任何疑洽助教,各位同。


有形介面肯定是用 JAVA 比方便,至於得好不好我不得。
但是居然後面助教有搞浮入,看真的需要有人比 ACM-ICPC,
才懂得如何表是一目的 input output


import javax.swing.*;
import java.awt.*;
import java.util.Scanner;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.PrintStream;

/**
 *
 * @author Shiang-Yun Yang
 *
 */
public class Rotate extends JFrame {
    public double px, py, qx, qy;
    public double tx, ty, ux, uy; // <point info>
    private int ox = 250, oy = 250;

    public Rotate(double n, String title) {
        this.setSize(500, 500);
        this.setResizable(false);
        this.setTitle(title);
        px = Math.cos(n) * (-50) - Math.sin(n) * 100;
        py = Math.sin(n) * (-50) + Math.cos(n) * 100;
        qx = Math.cos(n) * 50 - Math.sin(n) * 100;
        qy = Math.sin(n) * 50 + Math.cos(n) * 100;

        tx = Math.cos(n) * (-80) - Math.sin(n) * 130;
        ty = Math.sin(n) * (-80) + Math.cos(n) * 130;
        ux = Math.cos(n) * 80 - Math.sin(n) * 130;
        uy = Math.sin(n) * 80 + Math.cos(n) * 130;
    }

    public void paint(Graphics g) {
        for (int i = 0; i < 500; i++) {
            g.setColor(Color.WHITE);
            g.drawLine(i, 0, i, 500);
        }
        g.setColor(Color.BLACK);
        g.setFont(new Font("Monospaced", Font.BOLD, 15));
        g.drawLine(250, 0, 250, 500);
        g.drawLine(0, 250, 500, 250);

        g.fillOval(245, 245, 10, 10);
        g.drawString("(0,0)", 265, 265);

        int ax, ay, bx, by, cx, cy, dx, dy;
        ax = (int) Math.round(px) + ox;
        ay = oy - (int) Math.round(py);
        bx = (int) Math.round(tx) + ox;
        by = oy - (int) Math.round(ty);
        g.fillOval(ax - 5, ay - 5, 10, 10);
        g.drawString(String.format("(%.2f,%.2f)", px, py), bx, by);
        cx = (int) Math.round(qx) + ox;
        cy = oy - (int) Math.round(qy);
        dx = (int) Math.round(ux) + ox;
        dy = oy - (int) Math.round(uy);
        g.fillOval(cx - 5, cy - 5, 10, 10);
        g.drawString(String.format("(%.2f,%.2f)", qx, qy), dx, dy);
        g.drawLine(ax, ay, ox, oy);
        g.drawLine(cx, cy, ox, oy);
        g.drawLine(ax, ay, cx, cy);
    }

    public static void main(String[] args) {
        Scanner fin = null;
        PrintStream fout = null;
        try {
            fin = new Scanner(new FileInputStream("input.txt"));
            fout = new PrintStream(new FileOutputStream("output.txt"));
        } catch (Exception e) {
        }

        double n = fin.nextDouble();

        fout.println("Transform matrix:");
        fout.println("");
        fout.println("cos(" + n + ")  -sin(" + n + ")");
        fout.println("sin(" + n + ")  cos(" + n + ")");
        fout.println("");
        fout.println("The three coordinates:");
        fout.println("");
        fout.println("( 0.00 , 0.00 )");
       
        double px, py, qx, qy;
        n = n * Math.PI / 180;
        px = Math.cos(n) * (-50) - Math.sin(n) * 100;
        py = Math.sin(n) * (-50) + Math.cos(n) * 100;
        qx = Math.cos(n) * 50 - Math.sin(n) * 100;
        qy = Math.sin(n) * 50 + Math.cos(n) * 100;

        fout.printf("( %.2f, %.2f )", px, py);
        fout.println("");
        fout.printf("( %.2f, %.2f )", qx, qy);
        fout.println("");
        Rotate guiT = new Rotate(n, "Transform");
        Rotate guiO = new Rotate(0.0, "Origin");
        guiO.setVisible(true);
        guiT.setVisible(true);
        fin.close();
        fout.close();
    }
}

台: Morris
人(3,107) | 回(0)| 推 (0)| 收藏 (0)|
全站分: 不分 | 人分: 其他目 |
此分下一篇:[料][作] 霍夫曼
此分上一篇:[料] BST 的 construct & traversal

是 (若未登入"人新台"看不到回覆唷!)
* 入:
入片中算式的果(可能0) 
(有*必填)
TOP
全文
ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86