com.partnersoft.geometry.xy
Class XyRotation

java.lang.Object
  extended by com.partnersoft.geometry.xy.XyRotation
All Implemented Interfaces:
Immutable

public class XyRotation
extends java.lang.Object
implements Immutable

A rotation, expressed as an angle left (clockwise) or right (counter-clockwise).

Copyright 2007 Partner Software, Inc.

Version:
$Id$
Author:
Paul Reavis, Rich Stepanski, Richard Fay

Method Summary
 boolean equals(java.lang.Object obj)
           
 XyRotation flipped()
          Returns a modified version of this rotation with the angle flipped (leftTurn is set to the opposite of this deflection's setting).
static XyRotation forLeft(XyAngle angle)
          Returns the given rotation to the left.
static XyRotation forLeftDegrees(double degrees)
          Returns the given rotation in degrees to the left.
static XyRotation forLeftRadians(double radians)
          Returns the given rotation in radians to the left.
static XyRotation forRight(XyAngle angle)
          Returns the given rotation to the right.
static XyRotation forRightDegrees(double degrees)
          Returns the given rotation in degrees to the right.
static XyRotation forRightRadians(double radians)
          Returns the given rotation in radians to the right.
 XyAngle getAngle()
          Returns the rotation angle.
 double getLeftDegrees()
          Returns the rotation angle as a left turn (counter-clockwise) in degrees.
 double getLeftRadians()
          Returns the rotation angle as a left turn (counter-clockwise) in radians.
 double getRightDegrees()
          Returns the rotation angle as a right turn (clockwise) in degrees.
 double getRightRadians()
          Returns the rotation angle as a right turn (clockwise) in radians.
 boolean isClockwise()
          Returns true if rotation represents a right, or clockwise, turn.
 boolean isCounterClockwise()
          Returns true if rotation represents a left, or counter-clockwise turn.
 boolean isLeftTurn()
          Returns true if rotation represents a left, or counter-clockwise turn.
 boolean isRightTurn()
          Returns true if rotation represents a right, or clockwise, turn.
 boolean isStraight()
          Returns true if rotation is no rotation at all.
 XyRotation minus(XyRotation nother)
          Subtracts the given rotation from this one.
 XyRotation plus(XyRotation nother)
          Adds the given rotation to this one.
 XyRotation rotatedBy(XyRotation rotation)
          Uses the given XyRotation to rotate the given amount in the appropriate direction.
 XyRotation rotatedClockwiseBy(XyAngle angle)
          Uses the given XyAngle to rotate the given amount in the clockwise direction and return the result.
 XyRotation rotatedCounterClockwiseBy(XyAngle angle)
          Uses the given XyAngle to rotate the given amount in the counter-clockwise direction (widdershins!) and return the result.
 XyRotation rotatedWiddershinsBy(XyAngle angle)
          More flavorful (and also shorter) Lowland Scots term for rotatedCounterClockwiseBy(XyAngle).
 XyRotation times(double factor)
          Multiplies the rotation by the given factor.
 java.lang.String toString()
           
 XyRotation turnLeft(XyAngle angle)
          Synonym for rotatedCounterClockwiseBy(XyAngle).
 XyRotation turnRight(XyAngle angle)
          Synonym for rotatedClockwiseBy(XyAngle).
 XyRotation withAngle(XyAngle newAngle)
          Returns a modified version of this rotation with the given angle.
 XyRotation withLeftTurn(boolean newLeftTurn)
          Returns a modified version of this rotation with the given leftTurn flag.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

forLeft

public static XyRotation forLeft(XyAngle angle)
Returns the given rotation to the left.


forRight

public static XyRotation forRight(XyAngle angle)
Returns the given rotation to the right.


forLeftDegrees

public static XyRotation forLeftDegrees(double degrees)
Returns the given rotation in degrees to the left.


forRightDegrees

public static XyRotation forRightDegrees(double degrees)
Returns the given rotation in degrees to the right.


forLeftRadians

public static XyRotation forLeftRadians(double radians)
Returns the given rotation in radians to the left.


forRightRadians

public static XyRotation forRightRadians(double radians)
Returns the given rotation in radians to the right.


withAngle

public XyRotation withAngle(XyAngle newAngle)
Returns a modified version of this rotation with the given angle.


withLeftTurn

public XyRotation withLeftTurn(boolean newLeftTurn)
Returns a modified version of this rotation with the given leftTurn flag. If the flag is different from this one's setting it will effectively flip the result around the origin.


flipped

public XyRotation flipped()
Returns a modified version of this rotation with the angle flipped (leftTurn is set to the opposite of this deflection's setting).


rotatedBy

public XyRotation rotatedBy(XyRotation rotation)
Uses the given XyRotation to rotate the given amount in the appropriate direction.


rotatedClockwiseBy

public XyRotation rotatedClockwiseBy(XyAngle angle)
Uses the given XyAngle to rotate the given amount in the clockwise direction and return the result. Note that negative angles will actually rotate counter-clockwise.


rotatedCounterClockwiseBy

public XyRotation rotatedCounterClockwiseBy(XyAngle angle)
Uses the given XyAngle to rotate the given amount in the counter-clockwise direction (widdershins!) and return the result. Note that negative angles will actually rotate clockwise.


rotatedWiddershinsBy

public XyRotation rotatedWiddershinsBy(XyAngle angle)
More flavorful (and also shorter) Lowland Scots term for rotatedCounterClockwiseBy(XyAngle). See the wiki entry.


turnLeft

public XyRotation turnLeft(XyAngle angle)
Synonym for rotatedCounterClockwiseBy(XyAngle).


turnRight

public XyRotation turnRight(XyAngle angle)
Synonym for rotatedClockwiseBy(XyAngle).


plus

public XyRotation plus(XyRotation nother)
Adds the given rotation to this one. Has the same behavior as rotatedBy(XyRotation).


minus

public XyRotation minus(XyRotation nother)
Subtracts the given rotation from this one.


times

public XyRotation times(double factor)
Multiplies the rotation by the given factor.


equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getAngle

public XyAngle getAngle()
Returns the rotation angle.


isLeftTurn

public boolean isLeftTurn()
Returns true if rotation represents a left, or counter-clockwise turn.


isRightTurn

public boolean isRightTurn()
Returns true if rotation represents a right, or clockwise, turn.


isCounterClockwise

public boolean isCounterClockwise()
Returns true if rotation represents a left, or counter-clockwise turn.


isClockwise

public boolean isClockwise()
Returns true if rotation represents a right, or clockwise, turn.


isStraight

public boolean isStraight()
Returns true if rotation is no rotation at all.


getLeftRadians

public double getLeftRadians()
Returns the rotation angle as a left turn (counter-clockwise) in radians. Will be negative if the leftTurn is false.


getLeftDegrees

public double getLeftDegrees()
Returns the rotation angle as a left turn (counter-clockwise) in degrees. Will be negative if the leftTurn is false.


getRightRadians

public double getRightRadians()
Returns the rotation angle as a right turn (clockwise) in radians. Will be negative if the leftTurn is false.


getRightDegrees

public double getRightDegrees()
Returns the rotation angle as a right turn (clockwise) in degrees. Will be negative if the leftTurn is false.