Fix weight when translating object

pull/35/head
James Ball 2020-10-01 14:12:57 +01:00
rodzic ca9cf4c97b
commit bbc335862e
3 zmienionych plików z 14 dodań i 13 usunięć

Wyświetl plik

@ -12,10 +12,10 @@ import shapes.Vector2;
public class AudioClient {
private static final int SAMPLE_RATE = 192000;
private static final double OBJ_ROTATE = Math.PI / 1000;
private static final double OBJ_ROTATE = Math.PI / 100;
private static final float ROTATE_SPEED = 0;
private static final float TRANSLATION_SPEED = 0;
private static final Vector2 TRANSLATION = new Vector2(1, 1);
private static final Vector2 TRANSLATION = new Vector2(0.3, 0.3);
private static final float SCALE = 1;
private static final float WEIGHT = 80;
@ -26,11 +26,12 @@ public class AudioClient {
// Improve performance of line cleanup with a heuristic.
String objFilePath = args[0];
int numFrames = Integer.parseInt(args[1]);
float focalLength = Float.parseFloat(args[2]);
float cameraX = Float.parseFloat(args[3]);
float cameraY = Float.parseFloat(args[4]);
float cameraZ = Float.parseFloat(args[5]);
float focalLength = Float.parseFloat(args[1]);
float cameraX = Float.parseFloat(args[2]);
float cameraY = Float.parseFloat(args[3]);
float cameraZ = Float.parseFloat(args[4]);
int numFrames = (int) (2 * Math.PI / OBJ_ROTATE);
Camera camera = new Camera(focalLength, new Vector3(cameraX, cameraY, cameraZ));
WorldObject object = new WorldObject(objFilePath);

Wyświetl plik

@ -29,21 +29,21 @@ public final class Line extends Shape {
@Override
public Line rotate(double theta) {
return new Line(getA().rotate(theta), getB().rotate(theta), getWeight());
return new Line(a.rotate(theta), b.rotate(theta), weight);
}
@Override
public Line translate(Vector2 vector) {
return new Line(getA().translate(vector), getB().translate(vector));
return new Line(a.translate(vector), b.translate(vector), weight);
}
@Override
public Line scale(double factor) {
return new Line(getA().scale(factor), getB().scale(factor));
return new Line(a.scale(factor), b.scale(factor), weight);
}
public Line copy() {
return new Line(getA().copy(), getB().copy(), getWeight());
return new Line(a.copy(), b.copy(), weight);
}
@Override
@ -108,7 +108,7 @@ public final class Line extends Shape {
} else if (obj instanceof Line) {
Line line = (Line) obj;
return line.getA().equals(getA()) && line.getB().equals(getB());
return line.a.equals(a) && line.b.equals(b);
} else {
return false;
}

Wyświetl plik

@ -1,7 +1,7 @@
package shapes;
public abstract class Shape {
public static final int DEFAULT_WEIGHT = 1;
public static final int DEFAULT_WEIGHT = 100;
protected double weight;
protected double length;