import java.applet.*;
import java.awt.*;
import java.lang.Exception;
import java.lang.Cloneable;
public class Clifford extends Applet {
public class CliffException extends Exception{
public Cliff divident, divisor;
CliffException() {}
CliffException( String s ) {
super ( s );
}
CliffException( String s, Cliff cla, Cliff clb ){
super ( s );
divident = (Cliff) cla.clone();
divisor = (Cliff) clb.clone();
}
}
public class Cliff extends Object implements Cloneable {
// nur in 3 dimensionen zunächst
// und zunächst nur Skalar durch Vektor
public float scalar, pseudoscalar;
public float vektor[] = { (float) 0.0, (float) 0.0, (float) 0.0 };
public float pseudovektor[] = { (float) 0.0, (float) 0.0, (float) 0.0 };
public final float nullVektor[] = { (float) 0.0, (float) 0.0, (float) 0.0 };
public void Cliff() {
scalar = (float) 0.0;
pseudoscalar = (float) 0.0;
}
public Cliff divCliff(Cliff b) throws CliffException {
Cliff help = new Cliff();
float norm;
// soll das aktuelle Clifford Objekt durch das übergebene b dividieren
if ((b.vektor[0] == (float) 0.0 ) && (b.vektor[1] == (float) 0.0 ) &&
(b.vektor[2] == (float) 0.0 )) {
throw new CliffException( "Division Fehler " , this, b);
}
// nun die eigentliche Division wenn keine Ausnahme vorliegt, sodaß
// Ergebnis in this
norm = b.vektor[0]*b.vektor[0] + b.vektor[1]*b.vektor[1] +
b.vektor[2]*b.vektor[2];
help.vektor[0] = b.vektor[0] / norm;
help.vektor[1] = b.vektor[1] / norm;
help.vektor[2] = b.vektor[2] / norm;
return this;
}
public Object clone() {
Object ausgabe;
Cliff newClone = new Cliff();
newClone.pseudoscalar = this.pseudoscalar;
newClone.vektor[0] = this.vektor[0];
newClone.vektor[1] = this.vektor[1];
newClone.vektor[2] = this.vektor[2];
newClone.pseudovektor[0] = this.vektor[0];
newClone.pseudovektor[1] = this.vektor[1];
newClone.pseudovektor[2] = this.vektor[2];
ausgabe = (Object) newClone;
return ausgabe;
}
}
public void paint(Graphics test) {
Cliff num1 = new Cliff();
Cliff num2 = new Cliff();
Cliff num3 = new Cliff();
String s,t,u;
num1.scalar = (float) 5.0;
num3.vektor[0] = (float) 5.0;
num3.vektor[1] = (float) 3.333;
num3.vektor[2] = (float) -9.2;
try {
num2 = num1.divCliff(num2);
num1.scalar = (float) 17.3;
num3 = num1.divCliff(num2);
}
catch (CliffException ce) {
s = ce.getMessage();
t = s.valueOf(ce.divident.scalar);
u = s+t;
test.drawString(u,25,30);
}
test.drawString("Hello graphic",25,50);
}
}
|