All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mmb.engine.rotate.Chirality Maven / Gradle / Ivy

Go to download

Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world. THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<

There is a newer version: 0.6
Show newest version
/**
 * 
 */
package mmb.engine.rotate;

import java.util.EventListener;
import java.util.function.Consumer;

import mmb.NN;

/**
 * @author oskar
 * This enum defines chirality
 */
public enum Chirality {
	/**
	 * Describes anti-clockwise chirality, in order of [+X, -Y, -X, +Y]
	 */
	L {
		@Override
		public Rotation right(Rotation rotation) {
			return rotation.ccw();
		}

		@Override
		public Rotation left(Rotation rotation) {
			return rotation.cw();
		}

		@Override
		public Side right(Side rotation) {
			return rotation.ccw();
		}

		@Override
		public Side left(Side rotation) {
			return rotation.cw();
		}

		@Override
		public Chirality reverse() {
			return R;
		}

	},
	/**
	 * Describes clockwise chirality, in order of [+X, +Y, -X, -Y]
	 */
	R {
		@Override
		public Rotation right(Rotation rotation) {
			return rotation.cw();
		}

		@Override
		public Rotation left(Rotation rotation) {
			return rotation.ccw();
		}

		@Override
		public Side right(Side rotation) {
			return rotation.cw();
		}

		@Override
		public Side left(Side rotation) {
			return rotation.ccw();
		}

		@Override
		public Chirality reverse() {
			return L;
		}
	};
	
	/**
	 * Rotates the object in the chirality's "right" direction, meaning the same as positive
	 * @param rotation rotation to rotate
	 * @return rotated rotation
	 */
	public abstract @NN Rotation right(Rotation rotation);
	
	/**
	 * Rotates the object in the chirality's "left" direction, meaning the same as negative
	 * @param rotation rotation to rotate
	 * @return rotated rotation
	 */
	public abstract @NN Rotation left(Rotation rotation);
	/**
	 * Rotates the object in the chirality's "right" direction, meaning the same as positive
	 * @param rotation rotation to rotate
	 * @return rotated rotation
	 */
	public abstract @NN Side right(Side rotation);
	
	/**
	 * Rotates the object in the chirality's "left" direction, meaning the same as negative
	 * @param rotation rotation to rotate
	 * @return rotated rotation
	 */
	public abstract @NN Side left(Side rotation);
	
	/**
	 * @return reverse of this chirality
	 */
	public abstract @NN Chirality reverse();
	/**
	 * @author oskar
	 * Represents a chirality listener, used in chiral blocks
	 */
	public static interface ChiralityListener extends EventListener, Consumer{
		//unused
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy