Class pmr.euclid.Real2
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class pmr.euclid.Real2

java.lang.Object
   |
   +----pmr.euclid.Status
           |
           +----pmr.euclid.Real2

public class Real2
extends Status

Real2 - a pair of FPt numbers - no other assumptions

Contains two doubles. Can be used as-is, but there are some specialised derived classes (e.g. Complex (a complex number), Point2 (x,y coords), etc),

The default value is 0.0, 0.0.

Author:
(C) P. Murray-Rust, 1996

Constructor Index

 o Real2()
 o Real2(double, double)
 o Real2(Real2)
copy constructor

Method Index

 o clear()
set to 0, 0
 o dotProduct(Real2)
get dot product
 o elementAt(int)
get either value; counts from ZERO
 o equals(Real2)
 o getAngle(Real2, Real2, Real2)
get angle between 3 Real2s (the second is in the centre).
 o getLength()
get length of Real2 if centered on origin
 o getMidPoint(Real2)
point midway between 'this' and 'p'
 o getUnitVector()
get unit vector
 o getX()
get X value
 o getY()
get Y value
 o multiplyBy(double)
multiply a point by a scalar
 o negative()
multiply both components by -1; MODIFIES 'this'
 o plus(Real2)
add two points - vector sum;
 o setX(double)
 o setY(double)
 o sortAscending()
sorts x and y so that x <= y
 o sortDescending()
sorts x and y so that x >= y
 o subtract(Real2)
subtract two points - vector difference;
 o swap()
swaps the x and y values
 o toString()
 o transformBy(Transform2)
transforms the point by a rot-trans matrix; MODIFIES 'this'

Constructors

 o Real2
  public Real2()
 o Real2
  public Real2(double x,
               double y)
 o Real2
  public Real2(Real2 r)
copy constructor

Methods

 o swap
  public void swap()
swaps the x and y values
 o sortAscending
  public void sortAscending()
sorts x and y so that x <= y
 o sortDescending
  public void sortDescending()
sorts x and y so that x >= y
 o clear
  public void clear()
set to 0, 0
 o setX
  public void setX(double xx)
 o setY
  public void setY(double yy)
 o equals
  public boolean equals(Real2 r)
 o plus
  public Real2 plus(Real2 r2)
add two points - vector sum;
 o subtract
  public Real2 subtract(Real2 r2)
subtract two points - vector difference;
 o negative
  public void negative()
multiply both components by -1; MODIFIES 'this'
 o multiplyBy
  public Real2 multiplyBy(double f)
multiply a point by a scalar
 o getX
  public double getX()
get X value
 o getY
  public double getY()
get Y value
 o elementAt
  public double elementAt(int elem) throws ArrayIndexOutOfBoundsException
get either value; counts from ZERO
 o getLength
  public double getLength()
get length of Real2 if centered on origin
 o getMidPoint
  public Real2 getMidPoint(Real2 p)
point midway between 'this' and 'p'
 o getUnitVector
  public Real2 getUnitVector() throws ZeroLengthVectorException
get unit vector
Throws: ZeroLengthVectorException
this was of zero length
 o dotProduct
  public double dotProduct(Real2 r)
get dot product
 o getAngle
  public static Angle getAngle(Real2 p1,
                               Real2 p2,
                               Real2 p3)
get angle between 3 Real2s (the second is in the centre). angle is CLOCKWISE from p1 to p3
 o transformBy
  public void transformBy(Transform2 t)
transforms the point by a rot-trans matrix; MODIFIES 'this'
 o toString
  public String toString()
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index