geometry
Class AffineSpace

java.lang.Object
  extended bygeometry.AffineSpace
All Implemented Interfaces:
Geometry
Direct Known Subclasses:
HyperPlane, Line, Plane

public class AffineSpace
extends java.lang.Object
implements Geometry

An affine subspace of n-dimensional space. This is modelled by a point, and a matrix defining the associated vectorspace.

Affine spaces are the n-dimensional analogon to points, lines and planes in 3-space. The intersection of two affine spaces will again be an affine space (if it is not empty).

Author:
karsten

Field Summary
protected  Point origin
          any point, which is contained in the affine space
protected  JLinAlg.Matrix space
          a matrix, which contains the generators of the associated vectorspace as column-vectors
 
Constructor Summary
protected AffineSpace(JLinAlg.AffineLinearSubspace s)
          Converts an AffineLinearSubspace-object to an affineSpace
  AffineSpace(Point origin)
          Constructs a 0-dimensional affine space containig only the given point.
protected AffineSpace(Point origin, JLinAlg.Matrix space)
          Constructs an affine space from a Point in the affine space and a Matrix describing the associated vectorspace.
  AffineSpace(Point origin, Vector[] vectors)
          Constructs an affine space from a Point in the affine space and a set of vectors, generating the associated vectorspace.
protected AffineSpace(JLinAlg.Vector origin, JLinAlg.Matrix space)
          Constructs an affine space from a Point in the affine space (given as a vector) and a Matrix describing the associated vectorspace.
 
Method Summary
 void add(AffineSpace other)
          Enlarges this affine space, so that it will also contain another affine space.
 void add(Vector vector)
          Adds a vector to the set of generators of the associated vectorspace.
 AffineSpace affineClosure()
          Computes the smallest affine space, which contains this geometry
 boolean canBeContainedIn(Geometry other)
          Tests, if this geometry knows how to test if is contained in another geometry.
 boolean canContain(Geometry other)
          Tests, if this geometry knows how to test if it contains another geometry.
 boolean canIntersect(Geometry other)
          Tests, if this geometry knows how to intersect itself with another geometry.
 boolean contains(Geometry other)
          Checks, if a given point is contained in this affine space.
 boolean contains(Vector vector)
          Checks, if a given vector is contained the associated vector space.
 AffineSpace copy()
          Returns a deep copy of this affine space
 int dim()
          The dimension of this affine space
 Vector getGenerator(int i)
          Returns one of the generators of the associated vector space
 Vector getNormal(Point p)
          Returns a normal vector onto a hypersurface in a given point (only possible if dim()+1 == outerDim())
 Point getOrigin()
          Returns the origin of this affine space.
 Geometry getRandomRay(Point origin)
          Construct a random one-dimensional submanifold, containing a given point.
 Geometry intersection(Geometry geo)
          Computes the intersection of two affine spaces.
 boolean isContainedIn(Geometry other)
          Tests, if this geometry is contained in another geometry.
 Point localization(Point p)
          Returns the specified point in local coordinates.
 Vector localization(Vector vector)
          Returns the specified vector in local coordinates of the associated vector space.
 int outerDim()
          The dimension of the space, which contains this affine space as a subspace (thus the dimension of each point contained in this subspace).
 void print()
          Prints the origin and the set of generators of the associated vectorspace.
 Point project(Point p)
          Computes the orthogonal projection of a point onto this affine space.
 java.awt.Shape toShape(java.awt.geom.AffineTransform transform)
          Returns the cell as Shape (only possible for 2-dimensional Complexes).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

origin

protected Point origin
any point, which is contained in the affine space


space

protected JLinAlg.Matrix space
a matrix, which contains the generators of the associated vectorspace as column-vectors

Constructor Detail

AffineSpace

protected AffineSpace(Point origin,
                      JLinAlg.Matrix space)
Constructs an affine space from a Point in the affine space and a Matrix describing the associated vectorspace.

Parameters:
origin - any point contained in the affine space
space - a matrix containing the generators of the associated vectorspace as column-vectors

AffineSpace

protected AffineSpace(JLinAlg.Vector origin,
                      JLinAlg.Matrix space)
Constructs an affine space from a Point in the affine space (given as a vector) and a Matrix describing the associated vectorspace.

Parameters:
origin - a vector describing a point contained in the affine space
space - a matrix, containing the generators of the associated vectorspace as column-vectors

AffineSpace

protected AffineSpace(JLinAlg.AffineLinearSubspace s)
Converts an AffineLinearSubspace-object to an affineSpace

Parameters:
s - the affine subspace

AffineSpace

public AffineSpace(Point origin,
                   Vector[] vectors)
Constructs an affine space from a Point in the affine space and a set of vectors, generating the associated vectorspace.

Parameters:
origin - any point contained in the affine space
vectors - the generators of the associated vectorspace

AffineSpace

public AffineSpace(Point origin)
Constructs a 0-dimensional affine space containig only the given point.

Parameters:
origin - the only point in this affine space
Method Detail

copy

public AffineSpace copy()
Returns a deep copy of this affine space


add

public void add(Vector vector)
Adds a vector to the set of generators of the associated vectorspace. This will increase the dimension of the affine space. The given vector mustn't already be contained in this vectorspace.

Parameters:
vector - a new generator for the associated vectorspace

add

public void add(AffineSpace other)
Enlarges this affine space, so that it will also contain another affine space. The result will be the linear hull of both spaces (which is usually larger than their union).

Parameters:
other - the other affine space

dim

public int dim()
The dimension of this affine space

Specified by:
dim in interface Geometry
Returns:
the number of generators of the associated vectorspace

outerDim

public int outerDim()
The dimension of the space, which contains this affine space as a subspace (thus the dimension of each point contained in this subspace).

Specified by:
outerDim in interface Geometry
Returns:
the size of each generating vector

getOrigin

public Point getOrigin()
Returns the origin of this affine space.

Specified by:
getOrigin in interface Geometry
Returns:
the point whose localization is zero.

getGenerator

public Vector getGenerator(int i)
Returns one of the generators of the associated vector space

Parameters:
i - the index of a generator
Returns:
the generator selected by the index

print

public void print()
Prints the origin and the set of generators of the associated vectorspace.


contains

public boolean contains(Vector vector)
Checks, if a given vector is contained the associated vector space.

Parameters:
vector - a vector
Returns:
true iff the associated vector space conatins the vector v

contains

public boolean contains(Geometry other)
Checks, if a given point is contained in this affine space.

Specified by:
contains in interface Geometry
Parameters:
other - another geometry
Returns:
true iff the affine space conatins the point p

localization

public Vector localization(Vector vector)
Returns the specified vector in local coordinates of the associated vector space. If the vector is not contained in this vector space, this will return null.

Parameters:
vector - a vector which must be contained in the associated vector space
Returns:
the coordinates of the vector in the local coordinate system.

localization

public Point localization(Point p)
Returns the specified point in local coordinates. If the point is not contained in the space, this will return null.

Specified by:
localization in interface Geometry
Parameters:
p - a point which must lie in this space
Returns:
the coordinates of p in the local coordinate system.

project

public Point project(Point p)
Computes the orthogonal projection of a point onto this affine space. If the point is contained in this affine space, the result will be equal to the given point.

Parameters:
p - a point
Returns:
the orthogonal projection of p onto this affine space

affineClosure

public AffineSpace affineClosure()
Description copied from interface: Geometry
Computes the smallest affine space, which contains this geometry

Specified by:
affineClosure in interface Geometry
Returns:
the affine closure of this geometry

canIntersect

public boolean canIntersect(Geometry other)
Description copied from interface: Geometry
Tests, if this geometry knows how to intersect itself with another geometry.

Specified by:
canIntersect in interface Geometry
Parameters:
other - another geometry, which is to be intersected
Returns:
true if the method intersection will work

intersection

public Geometry intersection(Geometry geo)
Computes the intersection of two affine spaces. Returns null, if the given spaces do not intersect.

Specified by:
intersection in interface Geometry
Parameters:
geo - another geometry, which is to be intersected
Returns:
the intersection of this and the other affine space

canContain

public boolean canContain(Geometry other)
Description copied from interface: Geometry
Tests, if this geometry knows how to test if it contains another geometry. If the other geometry is a point, this has to be true.

Specified by:
canContain in interface Geometry
Parameters:
other - another geometry
Returns:
true if the method contains will work

canBeContainedIn

public boolean canBeContainedIn(Geometry other)
Description copied from interface: Geometry
Tests, if this geometry knows how to test if is contained in another geometry.

Specified by:
canBeContainedIn in interface Geometry
Parameters:
other - another geometry
Returns:
true if the method isContainedIn will work

isContainedIn

public boolean isContainedIn(Geometry other)
Description copied from interface: Geometry
Tests, if this geometry is contained in another geometry. If this geometry doesn't know, how to test this, it will throw an UnsupportedOperationException. This will happen only if canBeContainedIn returns false.

Specified by:
isContainedIn in interface Geometry
Parameters:
other - another geometry
Returns:
true iff this geometry contains other.

getRandomRay

public Geometry getRandomRay(Point origin)
Description copied from interface: Geometry
Construct a random one-dimensional submanifold, containing a given point. The point will become the origin of the compuded submanifold. The dimension of this geometry has to be nonzero.

Specified by:
getRandomRay in interface Geometry
Parameters:
origin - a point contained in this geometry
Returns:
a one-dimensional geometry, contained in this geometry, and containing the given origin

toShape

public java.awt.Shape toShape(java.awt.geom.AffineTransform transform)
Description copied from interface: Geometry
Returns the cell as Shape (only possible for 2-dimensional Complexes).

Specified by:
toShape in interface Geometry
Returns:
intersection as Shape

getNormal

public Vector getNormal(Point p)
Description copied from interface: Geometry
Returns a normal vector onto a hypersurface in a given point (only possible if dim()+1 == outerDim())

Specified by:
getNormal in interface Geometry
Parameters:
p - the starting point of the normal vector
Returns:
a vector orthogonal to the space in the point p