opale.m2d.ker
Class Vector2D

java.lang.Object
  |
  +--opale.m2d.ker.Object2D
        |
        +--opale.m2d.ker.Vector2D
All Implemented Interfaces:
java.lang.Cloneable, Transformable
Direct Known Subclasses:
GVector2D

public class Vector2D
extends Object2D
implements Transformable, java.lang.Cloneable

This class represents a vector in R².

Since:
Opale-2d 0.1
Author:
O.C.

Field Summary
 double x
          public members.
 double y
          public members.
 
Constructor Summary
Vector2D()
          Constructor by default.
Vector2D(OIJ rep)
          Constucts and intializes the vector at (0; 0) with a OIJ specified.
Vector2D(OIJ rep, double x, double y)
          Constucts and intializes the vector at (x; y) with a OIJ specified.
Vector2D(Point2D p, Point2D q)
          Constructs a vector from two objects Point2D.
Vector2D(Vector2D v)
          Constructs and initializes a vector with the same location as the specified Vector2D object.
 
Method Summary
 void changeOIJ(OIJ rep)
          Effectue un changement de repere du vecteur.
 java.lang.Object clone()
          Creates a new object of the same class and with the same contents as this vector.
 boolean equals(java.lang.Object obj)
          Determines whether two .vectors are equal.
 double getX()
          Returns the X coordinate of the vector.
 double getY()
          Returns the Y coordinate of the vector.
 double norm()
          Computes the norm of this vector.
static double norm(double x, double y)
          Computes the norm of a vector (x ; y).
static double norm(Vector2D v)
          Computes the norm of a vector v.
 double normSq()
          Computes the square of the norm of this vector.
static double normSq(double x, double y)
          Computes the square of the norm of a vector (x ; y).
static double normSq(Vector2D v)
          Computes the square of the norm of a vector v.
 int readKeyWord(java.lang.String word, RFile f, Pack2D p)
          Interpret a keyword read in a file.
 void rotate(double theta)
          Rotate l'objet graphique de l'angle theta autour de l'origine
 void rotate(double x, double y, double theta)
          Rotate l'objet graphique de l'angle theta autour d'un point
 void set(double x, double y)
          Sets the coordinates of this vector.
 void set(Vector2D v)
          Sets the coordinates of the vector to the specified vector.
 void setX(double x)
          Sets the X coordinate of this vector to the specified double coordinate.
 void setY(double y)
          Sets the Y coordinate of this vector to the specified double coordinate.
 java.lang.String toString()
          Returns a string representation of this object.
 void transform(AffineTransform2D t)
          Transforms the object by a general transform AffineTransform.
 void translate(double dx, double dy)
          Translate l'objet graphique du vecteur(dx, dy).
 void writeFileMore(WFile f, Pack2D p)
          Wrtie complementary information in a file.
 
Methods inherited from class opale.m2d.ker.Object2D
getOIJ, readFile, setOIJ, writeFile, xmax
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x
public members. The coordinates of the vector

y

public double y
public members. The coordinates of the vector
Constructor Detail

Vector2D

public Vector2D()
Constructor by default.

Vector2D

public Vector2D(OIJ rep)
Constucts and intializes the vector at (0; 0) with a OIJ specified.
Parameters:
OIJ - rep, the basis

Vector2D

public Vector2D(OIJ rep,
                double x,
                double y)
Constucts and intializes the vector at (x; y) with a OIJ specified.
Parameters:
OIJ - rep, the basis
double - x,y, coords of the vector.

Vector2D

public Vector2D(Vector2D v)
Constructs and initializes a vector with the same location as the specified Vector2D object.
Parameters:
Vector2D - v, a vector.

Vector2D

public Vector2D(Point2D p,
                Point2D q)
Constructs a vector from two objects Point2D.
Parameters:
Point2D - p, the origin
Point2D - q, the end
Method Detail

getX

public final double getX()
Returns the X coordinate of the vector.
Returns:
double, the X coordinate of this vector.

getY

public final double getY()
Returns the Y coordinate of the vector.
Returns:
double, the Y coordinate of this vector.

setX

public final void setX(double x)
Sets the X coordinate of this vector to the specified double coordinate.
Parameters:
double - x, the new X coordinate.

setY

public final void setY(double y)
Sets the Y coordinate of this vector to the specified double coordinate.
Parameters:
double - y, the new Y coordinate.

set

public final void set(double x,
                      double y)
Sets the coordinates of this vector.
Parameters:
x, - y, the coordinates of the vector.

set

public final void set(Vector2D v)
Sets the coordinates of the vector to the specified vector.
Parameters:
Vector2D - v, the specified vector.

normSq

public final double normSq()
Computes the square of the norm of this vector.
Returns:
double, the square of the norm.

norm

public final double norm()
Computes the norm of this vector.
Returns:
double, the norm.

normSq

public static final double normSq(double x,
                                  double y)
Computes the square of the norm of a vector (x ; y).
Parameters:
double - x,y, the coordinates of the vector.
Returns:
double, the square of the norm.

norm

public static double norm(double x,
                          double y)
Computes the norm of a vector (x ; y).
Parameters:
double - x,y, the coordinates of the vector.
Returns:
double, the norm.

normSq

public static double normSq(Vector2D v)
Computes the square of the norm of a vector v.
Parameters:
Vector2D - v, the vector.
Returns:
double, the square of the norm.

norm

public static double norm(Vector2D v)
Computes the norm of a vector v.
Parameters:
Vector2D - v, the vector.
Returns:
double, the norm.

equals

public boolean equals(java.lang.Object obj)
Determines whether two .vectors are equal.
Overrides:
equals in class java.lang.Object
Parameters:
Object - obj, an object to be compared with this vector.
Returns:
true the object to be compared is an instance of Vector2D and has the same value; false otherwise.

clone

public java.lang.Object clone()
Creates a new object of the same class and with the same contents as this vector.
Overrides:
clone in class Object2D
Returns:
Object, a clone of this instance.
Throws:
OutOfMemoryError - if there is not enough memory.
See Also:
Cloneable

translate

public void translate(double dx,
                      double dy)
Description copied from interface: Transformable
Translate l'objet graphique du vecteur(dx, dy).
Specified by:
translate in interface Transformable
Following copied from interface: opale.m2d.ker.Transformable
Parameters:
double - dx,dy, coordonées du vecteur de translation.

rotate

public void rotate(double theta)
Description copied from interface: Transformable
Rotate l'objet graphique de l'angle theta autour de l'origine
Specified by:
rotate in interface Transformable
Following copied from interface: opale.m2d.ker.Transformable
Parameters:
double - theta, l'angle de rotation en radian

rotate

public void rotate(double x,
                   double y,
                   double theta)
Description copied from interface: Transformable
Rotate l'objet graphique de l'angle theta autour d'un point
Specified by:
rotate in interface Transformable
Following copied from interface: opale.m2d.ker.Transformable
Parameters:
double - oriX, double oriY, le centre de la rotation
double - theta, l'angle de rotation en radian

transform

public void transform(AffineTransform2D t)
Description copied from interface: Transformable
Transforms the object by a general transform AffineTransform.
Specified by:
transform in interface Transformable
Following copied from interface: opale.m2d.ker.Transformable
Parameters:
AffineTransform, - the transform

changeOIJ

public void changeOIJ(OIJ rep)
Effectue un changement de repere du vecteur.
Overrides:
changeOIJ in class Object2D
Parameters:
OIJ - rep, le nouveau repere.

toString

public java.lang.String toString()
Description copied from class: Object2D
Returns a string representation of this object.
Overrides:
toString in class Object2D

writeFileMore

public void writeFileMore(WFile f,
                          Pack2D p)
Description copied from class: Object2D
Wrtie complementary information in a file.
Overrides:
writeFileMore in class Object2D
Following copied from class: opale.m2d.ker.Object2D
Parameters:
WFile - f, the file in writing .

readKeyWord

public int readKeyWord(java.lang.String word,
                       RFile f,
                       Pack2D p)
                throws java.io.IOException,
                       MalformedFileException
Description copied from class: Object2D
Interpret a keyword read in a file.
Overrides:
readKeyWord in class Object2D
Following copied from class: opale.m2d.ker.Object2D
Parameters:
String - word, the keyword.
RFile - f, the file in reading.
Pack2D - p, instance of Pack2D that contains the requiered objects.
Returns:
int, 0 if the keyword is good, -1 otherwise.