1 package net.mograsim.logic.model.model.components;
4 * For components that can have different orientations. The meaning is not clearly defined, however it is common that the orientation
5 * denotes the direction the output is facing or the general flow of signals. <code>_ALT</code> represents an alternative, which is normally
6 * a mirrored version. A component can choose to not support some variants.
8 * In terms of calculation, {@link #RIGHT} is considered the default.
10 * Note that this needs to be interpreted using the GUI coordinate system, meaning that UP and DOWN are swapped.
12 * @author Christian Femers
14 public enum Orientation
17 * The orientation <code>RIGHT</code> is the default orientation, all others are defined relative to it.
19 RIGHT(1, 0, 0, 1), LEFT(-1, 0, 0, -1), UP(0, 1, -1, 0), DOWN(0, -1, 1, 0), RIGHT_ALT(1, 0, 0, -1), LEFT_ALT(-1, 0, 0, 1),
20 UP_ALT(0, -1, -1, 0), DOWN_ALT(0, 1, 1, 0);
22 // simple 2D transformation matrix
28 private Orientation(double trans11, double trans12, double trans21, double trans22)
30 this.trans11 = trans11;
31 this.trans12 = trans12;
32 this.trans21 = trans21;
33 this.trans22 = trans22;
37 * Performs a simple rotation around the origin. This does not work for the display coordinate system.
39 * @return the point's new X coordinate
41 public double getNewX(double rightX, double rightY)
43 return rightX * trans11 + rightY * trans12;
47 * Performs a simple rotation around the origin. This does not work for the display coordinate system.
49 * @return the point's new Y coordinate
51 public double getNewY(double rightX, double rightY)
53 return rightX * trans21 + rightY * trans22;
56 public boolean doesMirror()
61 public boolean swapsWidthAndHeight()