java图形变换(HLG java实验课)

java图形变换(HLG java实验课)_第1张图片

import java.util.*;
import java.util.Scanner;
class H
{
protected double m;
}
class Yuan extends H
{
private double y1,y2,y3,y4,y5,y6;
public Yuan (double y1,double y2,double y3,double y4,double y5,double y6)
{
this.y1=y1;
this.y2=y2;
this.y3=y3;
this.y4=y4;
this.y5=y5;
this.y6=y6;
}
public void HH ()
{
if(y31)
{
y1+=y4;
y2+=y5;
}
else if(y32)
{
double r1=y1,r2=y2;
y1=(r1-y4)*Math.cos(y6)-(r2-y5)*Math.sin(y6)+y4;
y2=(r1-y4)*Math.sin(y6)+(r2-y5)*Math.cos(y6)+y5;
}
System.out.printf("(%.2f,%.2f)\n",y1,y2);
}
}
class Sanjiaoxing extends H
{
private double z1,z2,z3,z4,z5,z6,z7,z8;
public Sanjiaoxing (double z1,double z2,double z3,double z4,double z5,double z6,double z7,double z8)
{
this.z1=z1;
this.z2=z2;
this.z3=z3;
this.z4=z4;
this.z5=z5;
this.z6=z6;
this.z7=z7;
this.z8=z8;
}
public void HHH()
{
Scanner input=new Scanner(System.in);
if(z51)
{
z1+=z6;
z2+=z7;
z3+=z6;
z4+=z7;
}
else if(z52)
{
double r1=z1,r2=z2,r3=z3,r4=z4;
z1=(r1-z6)*Math.cos(z8)-(r2-z7)*Math.sin(z8)+z6;
z2=(r1-z6)*Math.sin(z8)+(r2-z7)*Math.cos(z8)+z7;
z4=(r3-z6)*Math.sin(z8)+(r4-z7)*Math.cos(z8)+z7;
z3=(r3-z6)*Math.cos(z8)-(r4-z7)*Math.sin(z8)+z6;
}
System.out.printf("(%.2f,%.2f)-(%.2f,%.2f)\n",z1,z2,z3,z4);
}
}
class Juxing extends H
{
private double s1,s2,s3,s4,s5,s6,s7;
public Juxing(double s1,double s2,double s3,double s4,double s5,double s6,double s7)
{
this.s1=s1;
this.s2=s2;
this.s3=s3;
this.s4=s4;
this.s5=s5;
this.s6=s6;
this.s7=s7;
}
public void HHHH()
{
if(s41)
{
s1+=s5;
s2+=s6;
}
else if(s42)
{
double r1=s1,r2=s2;
s1=(r1-s5)*Math.cos(s7)-(r2-s6)*Math.sin(s7)+s5;
s2=(r1-s5)*Math.sin(s7)+(r2-s6)*Math.cos(s7)+s6;
}
System.out.printf("(%.2f,%.2f)Radius:%.2f\n",s1,s2,s3);

}
}
class sjx extends H
{
private double o1,o2,o3,o4,o5,o6,o7,o8,o9,o0;
public sjx(double o1,double o2,double o3,double o4,double o5,double o6,double o7,double o8,double o9,double o0)
{
this.o1=o1;
this.o2=o2;
this.o3=o3;
this.o4=o4;
this.o5=o5;
this.o6=o6;
this.o7=o7;
this.o8=o8;
this.o9=o9;
this.o0=o0;
}
public void HHHH()
{
if(o71)
{
o1+=o8;
o2+=o9;
o3+=o8;
o4+=o9;
o5+=o8;
o6+=o9;
}
else if(o72)
{
double r1=o1,r2=o2,r3=o3,r4=o4,r5=o5,r6=o6;
o1=(r1-o8)*Math.cos(o0)-(r2-o9)*Math.sin(o0)+o8;
o2=(r1-o8)*Math.sin(o0)+(r2-o9)*Math.cos(o0)+o9;
o3=(r3-o8)*Math.cos(o0)-(r4-o9)*Math.sin(o0)+o8;
o4=(r3-o8)*Math.sin(o0)+(r4-o9)*Math.cos(o0)+o9;
o5=(r5-o8)Math.cos(o0)-(r6-o9)Math.sin(o0)+o8;
o6=(r5-o8)Math.sin(o0)+(r6-o9)Math.cos(o0)+o9;
}
System.out.printf("(%.2f,%.2f)-(%.2f,%.2f)-(%.2f,%.2f)\n",o1,o2,o3,o4,o5,o6);
}
}
public class NumG{
public static void main(String args[]){
Scanner input=new Scanner(System.in);
while (input.hasNextDouble())
{
double x;
x=input.nextDouble();
if (x1)
{
double y1,y2,y3,y4,y5,y6;
y1=input.nextDouble();
y2=input.nextDouble();
y3=input.nextDouble();
y4=input.nextDouble();
y5=input.nextDouble();
if(y32)
{y6=input.nextDouble();}
else
y6=0;
y6=(Math.PIy6)/180;
Yuan r=new Yuan(y1,y2,y3,y4,y5,y6);
r.HH();
}
else if(x2)
{
double z1,z2,z3,z4,z5,z6,z7,z8;
z1=input.nextDouble();
z2=input.nextDouble();
z3=input.nextDouble();
z4=input.nextDouble();
z5=input.nextDouble();
z6=input.nextDouble();
z7=input.nextDouble();
if(z52)
z8=input.nextDouble();
else
z8=0;
z8=(Math.PIz8)/180;
Sanjiaoxing k=new Sanjiaoxing(z1,z2,z3,z4,z5,z6,z7,z8);
k.HHH();
}
else if (x3)
{
double s1,s2,s3,s4,s5,s6,s7;
s1=input.nextDouble();
s2=input.nextDouble();
s3=input.nextDouble();
s4=input.nextDouble();
s5=input.nextDouble();
s6=input.nextDouble();
if(s42)
s7=input.nextDouble();
else
s7=0;
s7=(Math.PIs7)/180;
Juxing j=new Juxing(s1,s2,s3,s4,s5,s6,s7);
j.HHHH();
}
else if (x4)
{
double o1,o2,o3,o4,o5,o6,o7,o8,o9,o0;
o1=input.nextDouble();
o2=input.nextDouble();
o3=input.nextDouble();
o4=input.nextDouble();
o5=input.nextDouble();
o6=input.nextDouble();
o7=input.nextDouble();
o8=input.nextDouble();
o9=input.nextDouble();
if(o72)
{o0=input.nextDouble();
}
else
o0=0;
o0=(Math.PIo0)/180;
sjx j=new sjx(o1,o2,o3,o4,o5,o6,o7,o8,o9,o0);
j.HHHH();
}
}
}
}

///(没有缩进,凑合看吧)

你可能感兴趣的:(java做题)