mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Added Transform.inverse() as a standard operation.
This commit is contained in:
parent
a74bab7f98
commit
63411b427a
@ -21,8 +21,10 @@ package com.sk89q.worldedit.math.transform;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
@ -60,6 +62,15 @@ public class CombinedTransform implements Transform {
|
|||||||
return vector;
|
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
|
@Override
|
||||||
public Transform combine(Transform other) {
|
public Transform combine(Transform other) {
|
||||||
checkNotNull(other);
|
checkNotNull(other);
|
||||||
|
@ -31,6 +31,11 @@ public class Identity implements Transform {
|
|||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Transform inverse() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Transform combine(Transform other) {
|
public Transform combine(Transform other) {
|
||||||
if (other instanceof Identity) {
|
if (other instanceof Identity) {
|
||||||
|
@ -27,6 +27,13 @@ import com.sk89q.worldedit.Vector;
|
|||||||
*/
|
*/
|
||||||
public interface Transform extends Function<Vector, 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.
|
* Create a new {@link Transform} that combines this transform with another.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user