Skip to content
Snippets Groups Projects
Commit 8539c4ad authored by Edvard Berdal Eek's avatar Edvard Berdal Eek
Browse files

Implementation of variables and methods in transformations classes

parent 7f8974fa
No related branches found
No related tags found
1 merge request!2Feat/transformations
Pipeline #257710 failed
package org.example.chaosgame.transformations; package org.example.chaosgame.transformations;
import org.example.chaosgame.linalg.Matrix2x2;
import org.example.chaosgame.linalg.Vector2D;
public class AffineTransform2D implements Transform2D{ public class AffineTransform2D implements Transform2D{
private final Matrix2x2 matrix;
private final Vector2D vector;
public AffineTransform2D(Matrix2x2 matrix, Vector2D vector) {
this.matrix = matrix;
this.vector = vector;
}
@Override
public Vector2D transform(Vector2D point) {
return matrix.multiply(point).add(vector);
}
} }
package org.example.chaosgame.transformations; package org.example.chaosgame.transformations;
import org.example.chaosgame.linalg.Complex;
import org.example.chaosgame.linalg.Vector2D;
public class JuliaTransform implements Transform2D{ public class JuliaTransform implements Transform2D{
private final Complex point;
private final int sign;
public JuliaTransform(Complex point, int sign) {
this.point = point;
this.sign = sign;
}
@Override
public Vector2D transform(Vector2D point) {
Vector2D result = this.point.sqrt(point.getX(), point.getY());
double a = sign * result.getX();
double b = sign * result.getY();
return new Vector2D(a, b);
}
} }
package org.example.chaosgame.transformations; package org.example.chaosgame.transformations;
import org.example.chaosgame.linalg.Vector2D;
public interface Transform2D{ public interface Transform2D{
public Vector2D transform(Vector2D point);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment