3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 10:30:04 +01:00

Added Transform.inverse() as a standard operation.

Dieser Commit ist enthalten in:
sk89q 2014-07-01 12:41:11 -07:00
Ursprung a74bab7f98
Commit 63411b427a
3 geänderte Dateien mit 23 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -21,8 +21,10 @@ package com.sk89q.worldedit.math.transform;
import com.sk89q.worldedit.Vector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
@ -60,6 +62,15 @@ public class CombinedTransform implements Transform {
return vector;
}
@Override
public Transform inverse() {
List<Transform> list = new ArrayList<Transform>();
for (int i = transforms.length - 1; i >= 0; i--) {
list.add(transforms[i].inverse());
}
return new CombinedTransform(list);
}
@Override
public Transform combine(Transform other) {
checkNotNull(other);

Datei anzeigen

@ -31,6 +31,11 @@ public class Identity implements Transform {
return vector;
}
@Override
public Transform inverse() {
return this;
}
@Override
public Transform combine(Transform other) {
if (other instanceof Identity) {

Datei anzeigen

@ -27,6 +27,13 @@ import com.sk89q.worldedit.Vector;
*/
public interface Transform extends Function<Vector, Vector> {
/**
* Create a new inverse transform.
*
* @return a new inverse transform
*/
Transform inverse();
/**
* Create a new {@link Transform} that combines this transform with another.
*