public class ProjectiveOperator extends AbstractCoordinateTransformationOperator implements CoordinateTransformationOperator
Projective operator (projective transformation):
y = y_{0}
y_{1}
...
y_{n−1}= (A_{0}x + b_{0}) / (cx + d)
(A_{1}x + b_{1}) / (cx + d)
...
(A_{n−1}x + b_{n−1}) / (cx + d)= (a_{00}x_{0} + a_{01}x_{1} + ... + a_{0,n−1}x_{n−1} + b_{0}) / (c_{0}x_{0} + c_{1}x_{1} + ... + c_{n−1}x_{n−1} + d)
(a_{10}x_{0} + a_{11}x_{1} + ... + a_{1,n−1}x_{n−1} + b_{1}) / (c_{0}x_{0} + c_{1}x_{1} + ... + c_{n−1}x_{n−1} + d)
...
(a_{n−1,0}x_{0} + a_{n−1,1}x_{1} + ... + a_{n−1,n−1}x_{n−1} + b_{n−1}) / (c_{0}x_{0} + c_{1}x_{1} + ... + c_{n−1}x_{n−1} + d)
All calculations are performed in strictfp mode, so the result is absolutely identical on all platforms.
However, please note: we do not guarantee that the divisions in the formulas above are performed strictly by "c=a/b" Java operator. They are possibly performed via the following code: "temp=1.0/b; c=a*temp;" The difference here is very little and not important for most practical needs.
Please note: if c vector is zero (all c_{i}=0) —
in other words, if this transformation is really affine — then an instance of this class
is always an instance of its inheritor LinearOperator
.
This rule is provided by the instantiation methods
getInstance(double[], double[], double[], double)
getInstance} and
getInstanceByPoints(net.algart.math.Point[], net.algart.math.Point[])
getInstanceByPoints}.
This class is immutable and threadsafe: there are no ways to modify settings of the created instance.
AlgART Laboratory 2007–2014
LinearOperator
Modifier and Type  Method and Description 

double[] 
a()
Returns an array containing A matrix.

double[] 
b()
Returns an array containing b vector.

double[] 
c()
Returns an array containing c vector.

double 
d()
Returns the d parameter.

double[] 
diagonal()
Returns an array containing the main diagonal of A matrix.

boolean 
equals(java.lang.Object obj)
Indicates whether some other object is also a
coordinate transformation operator , performing the same coordinate transformation as this one. 
static ProjectiveOperator 
getInstance(double[] a,
double[] b,
double[] c,
double d)
Returns an instance of this class, describing the projective operator with the specified matrix A,
the vectors b and c and the number d.

static ProjectiveOperator 
getInstanceByPoints(Point[] q,
Point[] p)
Returns the ndimensional projective operator, that transforms (maps)
the given n+2 points
p_{0}, p_{1}, ..., p_{n+1} to
the given another n+2 points
q_{0}, q_{1}, ..., q_{n+1}
of the ndimensional space.

int 
hashCode()
Returns the hash code of this object.

boolean 
isDiagonal()
Returns true if and only if A matrix is diagonal,
i.e. if a_{ij}=0.0 when i!=j.

boolean 
isShift()
Returns true if and only if A matrix is identity
(i.e. if a_{ij}=0.0 when i!=j and
a_{ij}=1.0 when i==j)
and c vector is zero.

boolean 
isZeroB()
Returns true if and only if the b vector is zero,
i.e. if b_{i}=0.0 for all i.

void 
map(double[] destPoint,
double[] srcPoint)
This implementation calculates destPoint by the formula

int 
n()
Returns the number of dimensions.

java.lang.String 
toString()
Returns a brief string description of this object.

apply
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
apply
public static ProjectiveOperator getInstance(double[] a, double[] b, double[] c, double d)
comments to this class
for more details.
The coordinates of the vectors b and c must be listed in b and c arrays.
The elements of the matrix A must be listed, row by row, in the a array:
A={a_{ij}},
a_{ij}=a[i*n+j],
i is the index of the row (0..n1),
j is the index of the column (0..n1),
n=b.length.
The lengths of b and c arrays must be the same: b.length=c.length=n.
The length a.length of the a array must be equal to its square n^{2}.
Empty arrays (n=0) are not allowed.
Please note: the returned operator can have another A, b, c, d parameters
(returned by a()
, b()
, c()
, d()
methods),
than specified in the arguments of this method.
Namely, all these numbers can be multiplied by some constant: such modification does not change
the projective transformation.
In particular, if the arguments of this method really describe
an affine transformation (c=0), then this method
returns an instance of LinearOperator
class, where all elements of A matrix
and b vector are divided by d number.
The passed a, b and c Java arrays are cloned by this method: no references to them are maintained by the created instance.
a
 the elements of A matrix.b
 the coordinates of b vector.c
 the coordinates of c vector.d
 the d parameter.java.lang.NullPointerException
 if one of the arguments of the method is null.java.lang.IllegalArgumentException
 if b.length==0, c.length==0, b.length!=c.length
or a.length!=b.length^{2}.public static ProjectiveOperator getInstanceByPoints(Point[] q, Point[] p)
d = 1.0; (A_{0}p_{k} + b_{0}) / (cp_{k} + 1)
(A_{1}p_{k} + b_{1}) / (cp_{k} + 1)
...
(A_{n−1}p_{k} + b_{n−1}) / (cp_{k} + 1)= q_{k0}
q_{k1}
...
q_{k,n−1}= q_{k} for k = 0, 1, ..., n+1
(a_{i} means the line i of the matrix A). It is possible that there is no such operator or there are many different solutions (degenerated cases). In this case, this method still returns some operator, but some coefficients of A matrix, b and c vectors in the returned operator will probably be Double.NaN, Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY.
All passed points must be ndimensional, where n+2=p.length=q.length.
q
 the destination points.p
 the source points.java.lang.NullPointerException
 if one of arguments of this method or one of elements of
p and q arrays null.java.lang.IllegalArgumentException
 if the lengths of the passed p and q arrays are not equal,
or if for some k
p[k].coordCount()
!=p.length2 or
q[k].coordCount()
!=p.length2.java.lang.OutOfMemoryError
 if there is not enough Java memory for storing Java array
double[n*(n+2)*n*(n+2)],
where n+2=p.length,
or if n*(n+2)*n*(n+2)>Integer.MAX_VALUE.public final double[] a()
The returned array is always newly created: it is not a reference to some internal data stored in this object.
java.lang.OutOfMemoryError
 if this instance was created by some creation method of
the LinearOperator
class,
besides LinearOperator.getInstance(double[], double[])
,
and the matrix is too large to be stored in Java memory
or its size is greater than Integer.MAX_VALUE.public final double[] b()
The returned array is always newly created: it is not a reference to some internal data stored in this object.
public final double[] c()
LinearOperator
, the result is always zerofilled.
The returned array is always newly created: it is not a reference to some internal data stored in this object.
public final double d()
LinearOperator
, the result is always 0.0.public final double[] diagonal()
The returned array is always newly created: it is not a reference to some internal data stored in this object.
public final int n()
public final boolean isDiagonal()
public final boolean isShift()
LinearOperator
.public final boolean isZeroB()
isZeroB()
&& isShift()
,
this operator is identity: it doesn't change the passed function.public void map(double[] destPoint, double[] srcPoint)
this class
.map
in interface CoordinateTransformationOperator
map
in class AbstractCoordinateTransformationOperator
destPoint
 the coordinates of the destinated point y, filled by this method.srcPoint
 the coordinates of the source point x.java.lang.NullPointerException
 if one of the arguments is null.java.lang.IllegalArgumentException
 if destPoint.length or srcPoint.length
is not equal to the number of dimensions
.public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
CoordinateTransformationOperator
hashCode
in interface CoordinateTransformationOperator
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
CoordinateTransformationOperator
coordinate transformation operator
, performing the same coordinate transformation as this one.
There is high probability, but no guarantee that this method returns true if the passed operator specifies a transformation, identical to this one. There is a guarantee that this method returns false if the passed operator specifies a transformation, different than this one.
equals
in interface CoordinateTransformationOperator
equals
in class java.lang.Object
obj
 the object to be compared for equality with this operator.