Skip to content
Snippets Groups Projects
Commit 79c98dfc authored by Edvard Granheim Harbo's avatar Edvard Granheim Harbo Committed by Tam Minh Le
Browse files

Task.1.2 finished

parent 3b17db31
Branches
No related tags found
1 merge request!2Task.1.2 finished
package edu.ntnu.idatt2003.mappevurderingprog2;
public class Complex extends Vector2D{
public Complex(double realPart, double imaginaryPart) {
super(realPart, imaginaryPart);
}
public Complex sqrt() {
double r = Math.sqrt(Math.pow(getX0(), 2) + Math.pow(getX1(), 2));
double theta = Math.atan2(getX1(), getX0());
return new Complex(Math.sqrt(r) * Math.cos(theta / 2), Math.sqrt(r) * Math.sin(theta / 2));
}
}
\ No newline at end of file
package edu.ntnu.idatt2003.mappevurderingprog2;
public class Matrix2x2 {
private double a00;
private double a01;
private double a10;
private double a11;
public Matrix2x2(double a00, double a01, double a10, double a11) {
this.a00 = a00;
this.a01 = a01;
this.a10 = a10;
this.a11 = a11;
}
public Vector2D multiply(Vector2D vector) {
return new Vector2D(a00 * vector.getX0() + a01 * vector.getX1(), a10 * vector.getX0() + a11 * vector.getX1());
}
}
\ No newline at end of file
package edu.ntnu.idatt2003.mappevurderingprog2;
import java.util.Vector;
public class Vector2D {
private double x0;
private double x1;
public Vector2D(double x0, double x1) {
this.x0 = x0;
this.x1 = x1;
}
public double getX0() {
return x0;
}
public double getX1() {
return x1;
}
public Vector2D add(Vector2D other) {
return new Vector2D(x0 + other.x0, x1 + other.x1);
}
public Vector2D subtract(Vector2D other) {
return new Vector2D(x0 - other.x0, x1 - other.x1);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment