Class R2

java.lang.Object
xal.tools.math.r2.R2
All Implemented Interfaces:
Serializable

public class R2 extends Object implements Serializable
Class representing a point on the plane in R2.
Author:
Christopher Allen
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    R2()
    Creates a new instance of R2, the zero element.
    R2(double x1, double x2)
    Creates a new instance of R2 initialized to arguments.
    R2(R2 vecPt)
    Creates a new instance of R2 initialized to argument.
  • Method Summary

    Modifier and Type
    Method
    Description
    Apply coordinate transform from cartesian to polar coordinates.
    Performs a deep copy operation.
    double
    Return first coordinate value.
    double
    Return second coordinate value.
    double
    Return first coordinate value.
    double
    Return second coordinate value.
    minus(R2 r)
    Vector subtraction.
    double
    Compute the l2 norm of the vector in R2.
    plus(R2 r)
    Vector addition.
    Apply coordinate transform from polar to cartesian coordinates
    void
    Print out centents on an output stream.
    void
    Print out centents on an output stream, terminate with new line character.
    void
    set(double s)
    Set all coordinates to value
    void
    set1(double x1)
    Set first coordinate value.
    void
    set2(double x2)
    Set second coordinate value.
    void
    setx(double x)
    Set first coordinate value.
    void
    sety(double y)
    Set second coordinate value.
    times(double s)
    Scalar multiplication.
    times(R2 r)
    Vector multiplication, i.e. complex multiplication.
    Convert to a string representation

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • R2

      public R2()
      Creates a new instance of R2, the zero element.
    • R2

      public R2(double x1, double x2)
      Creates a new instance of R2 initialized to arguments.
      Parameters:
      x1 - first coordinate value
      x2 - first coordinate value
    • R2

      public R2(R2 vecPt)
      Creates a new instance of R2 initialized to argument.
      Parameters:
      vecPt - deep copies this value
  • Method Details

    • copy

      public R2 copy()
      Performs a deep copy operation.
      Returns:
      cloned R3 object
    • set1

      public void set1(double x1)
      Set first coordinate value.
    • set2

      public void set2(double x2)
      Set second coordinate value.
    • setx

      public void setx(double x)
      Set first coordinate value.
    • sety

      public void sety(double y)
      Set second coordinate value.
    • set

      public void set(double s)
      Set all coordinates to value
    • get1

      public double get1()
      Return first coordinate value.
    • get2

      public double get2()
      Return second coordinate value.
    • getx

      public double getx()
      Return first coordinate value.
    • gety

      public double gety()
      Return second coordinate value.
    • cartesian2Polar

      public R2 cartesian2Polar()
      Apply coordinate transform from cartesian to polar coordinates.
      Returns:
      polar coordinates (r,phi) of this cartesian point
    • polar2Cartesian

      public R2 polar2Cartesian()
      Apply coordinate transform from polar to cartesian coordinates
      Returns:
      cartesian coordinates (x,y) of this polar point
    • times

      public R2 times(double s)
      Scalar multiplication.
      Parameters:
      s - scalar to multiply this vector
      Returns:
      new R2 object scaled by s
    • plus

      public R2 plus(R2 r)
      Vector addition.
      Parameters:
      r - vector displacement
      Returns:
      new R3 object equal to this displaced by r
    • minus

      public R2 minus(R2 r)
      Vector subtraction.
      Parameters:
      r - vector displacement
      Returns:
      new R3 object equal to this displaced by r
    • times

      public R2 times(R2 r)
      Vector multiplication, i.e. complex multiplication.
      Parameters:
      r - second (right) operand in cross-product (this is first operand)
      Returns:
      result of vector cross product in three space
    • norm2

      public double norm2()
      Compute the l2 norm of the vector in R2.
      Returns:
      l2 norm = (x1^2 + x2^2)^1/2
    • toString

      public String toString()
      Convert to a string representation
      Overrides:
      toString in class Object
      Returns:
      string in standard format "(x1,x2)"
    • print

      public void print(PrintWriter os)
      Print out centents on an output stream.
      Parameters:
      os - output stream receive content dump
    • println

      public void println(PrintWriter os)
      Print out centents on an output stream, terminate with new line character.
      Parameters:
      os - output stream receive content dump