org.apache.commons.math3.geometry.Vector Java Examples

The following examples show how to use org.apache.commons.math3.geometry.Vector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NPEfix_00171_t.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public Vector2D apply(final Vector<Euclidean2D> point) {
    final Vector2D p2D = (Vector2D) point;
    final double  x   = p2D.getX();
    final double  y   = p2D.getY();
    return new Vector2D(cXX * x + cXY * y + cX1,
                       cYX * x + cYY * y + cY1);
}
 
Example #2
Source File: NPEfix_00168_t.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public Vector2D apply(final Vector<Euclidean2D> point) {
    final Vector2D p2D = (Vector2D) point;
    final double  x   = p2D.getX();
    final double  y   = p2D.getY();
    return new Vector2D(cXX * x + cXY * y + cX1,
                       cYX * x + cYY * y + cY1);
}
 
Example #3
Source File: Vector1DFormat.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public StringBuffer format(final Vector<Euclidean1D> vector, final StringBuffer toAppendTo,
                           final FieldPosition pos) {
    final Vector1D p1 = (Vector1D) vector;
    return format(toAppendTo, pos, p1.getX());
}
 
Example #4
Source File: Vector3D.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public double distance(Vector<Euclidean3D> v) {
    final Vector3D v3 = (Vector3D) v;
    final double dx = v3.x - x;
    final double dy = v3.y - y;
    final double dz = v3.z - z;
    return FastMath.sqrt(dx * dx + dy * dy + dz * dz);
}
 
Example #5
Source File: Vector1DFormat.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public StringBuffer format(final Vector<Euclidean1D> vector, final StringBuffer toAppendTo,
                           final FieldPosition pos) {
    final Vector1D p1 = (Vector1D) vector;
    return format(toAppendTo, pos, p1.getX());
}
 
Example #6
Source File: Vector3D.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public double distanceInf(Vector<Euclidean3D> v) {
    final Vector3D v3 = (Vector3D) v;
    final double dx = FastMath.abs(v3.x - x);
    final double dy = FastMath.abs(v3.y - y);
    final double dz = FastMath.abs(v3.z - z);
    return FastMath.max(FastMath.max(dx, dy), dz);
}
 
Example #7
Source File: Cardumen_00110_s.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public double distanceSq(Vector<Euclidean3D> v) {
    final Vector3D v3 = (Vector3D) v;
    final double dx = v3.x - x;
    final double dy = v3.y - y;
    final double dz = v3.z - z;
    return dx * dx + dy * dy + dz * dz;
}
 
Example #8
Source File: Cardumen_00110_s.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public double distanceInf(Vector<Euclidean3D> v) {
    final Vector3D v3 = (Vector3D) v;
    final double dx = FastMath.abs(v3.x - x);
    final double dy = FastMath.abs(v3.y - y);
    final double dz = FastMath.abs(v3.z - z);
    return FastMath.max(FastMath.max(dx, dy), dz);
}
 
Example #9
Source File: NPEfix_00163_t.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public Vector2D apply(final Vector<Euclidean2D> point) {
    final Vector2D p2D = (Vector2D) point;
    final double  x   = p2D.getX();
    final double  y   = p2D.getY();
    return new Vector2D(cXX * x + cXY * y + cX1,
                       cYX * x + cYY * y + cY1);
}
 
Example #10
Source File: Vector2D.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public double distanceInf(Vector<Euclidean2D> p) {
    Vector2D p3 = (Vector2D) p;
    final double dx = FastMath.abs(p3.x - x);
    final double dy = FastMath.abs(p3.y - y);
    return FastMath.max(dx, dy);
}
 
Example #11
Source File: Cardumen_00110_s.java    From coming with MIT License 5 votes vote down vote up
/** Compute the cross-product of the instance with another vector.
 * @param v other vector
 * @return the cross product this ^ v as a new Vector3D
 */
public Vector3D crossProduct(final Vector<Euclidean3D> v) {
    final Vector3D v3 = (Vector3D) v;
    return new Vector3D(MathArrays.linearCombination(y, v3.z, -z, v3.y),
                        MathArrays.linearCombination(z, v3.x, -x, v3.z),
                        MathArrays.linearCombination(x, v3.y, -y, v3.x));
}
 
Example #12
Source File: AbstractRegion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public Vector<S> getBarycenter() {
    if (barycenter == null) {
        computeGeometricalProperties();
    }
    return barycenter;
}
 
Example #13
Source File: Vector2D.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public double distanceInf(Vector<Euclidean2D> p) {
    Vector2D p3 = (Vector2D) p;
    final double dx = FastMath.abs(p3.x - x);
    final double dy = FastMath.abs(p3.y - y);
    return FastMath.max(dx, dy);
}
 
Example #14
Source File: NPEfix_00164_t.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public Vector2D apply(final Vector<Euclidean2D> point) {
    final Vector2D p2D = (Vector2D) point;
    final double  x   = p2D.getX();
    final double  y   = p2D.getY();
    return new Vector2D(cXX * x + cXY * y + cX1,
                       cYX * x + cYY * y + cY1);
}
 
Example #15
Source File: Cardumen_0040_t.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public double distance1(Vector<Euclidean3D> v) {
    final Vector3D v3 = (Vector3D) v;
    final double dx = FastMath.abs(v3.x - x);
    final double dy = FastMath.abs(v3.y - y);
    final double dz = FastMath.abs(v3.z - z);
    return dx + dy + dz;
}
 
Example #16
Source File: Vector2D.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public double distanceSq(Vector<Euclidean2D> p) {
    Vector2D p3 = (Vector2D) p;
    final double dx = p3.x - x;
    final double dy = p3.y - y;
    return dx * dx + dy * dy;
}
 
Example #17
Source File: 1_Vector3D.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public double distanceInf(Vector<Euclidean3D> v) {
    final Vector3D v3 = (Vector3D) v;
    final double dx = FastMath.abs(v3.x - x);
    final double dy = FastMath.abs(v3.y - y);
    final double dz = FastMath.abs(v3.z - z);
    return FastMath.max(FastMath.max(dx, dy), dz);
}
 
Example #18
Source File: Cardumen_0040_t.java    From coming with MIT License 5 votes vote down vote up
/** Compute the cross-product of the instance with another vector.
 * @param v other vector
 * @return the cross product this ^ v as a new Vector3D
 */
public Vector3D crossProduct(final Vector<Euclidean3D> v) {
    final Vector3D v3 = (Vector3D) v;
    return new Vector3D(MathArrays.linearCombination(y, v3.z, -z, v3.y),
                        MathArrays.linearCombination(z, v3.x, -x, v3.z),
                        MathArrays.linearCombination(x, v3.y, -y, v3.x));
}
 
Example #19
Source File: NPEfix_00160_t.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public Vector2D apply(final Vector<Euclidean2D> point) {
    final Vector2D p2D = (Vector2D) point;
    final double  x   = p2D.getX();
    final double  y   = p2D.getY();
    return new Vector2D(cXX * x + cXY * y + cX1,
                       cYX * x + cYY * y + cY1);
}
 
Example #20
Source File: Vector3D.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public double distanceInf(Vector<Euclidean3D> v) {
    final Vector3D v3 = (Vector3D) v;
    final double dx = FastMath.abs(v3.x - x);
    final double dy = FastMath.abs(v3.y - y);
    final double dz = FastMath.abs(v3.z - z);
    return FastMath.max(FastMath.max(dx, dy), dz);
}
 
Example #21
Source File: Vector2D.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc}
 */
public double distance(Vector<Euclidean2D> p) {
    return distance((Point<Euclidean2D>) p);
}
 
Example #22
Source File: OrientedPoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double getOffset(final Vector<Euclidean1D> point) {
    final double delta = ((Vector1D) point).getX() - location.getX();
    return direct ? delta : -delta;
}
 
Example #23
Source File: JGenProg2017_0022_t.java    From coming with MIT License 4 votes vote down vote up
/** Set the barycenter of the instance.
 * @param barycenter barycenter of the instance
 */
protected void setBarycenter(final Vector<S> barycenter) {
    this.barycenter = barycenter;
}
 
Example #24
Source File: NPEfix_00188_t.java    From coming with MIT License 4 votes vote down vote up
/** {@inheritDoc}
 * @see #getAbscissa(Vector3D)
 */
public Vector1D toSubSpace(final Vector<Euclidean3D> point) {
    return new Vector1D(getAbscissa((Vector3D) point));
}
 
Example #25
Source File: Vector1D.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public Vector1D add(double factor, Vector<Euclidean1D> v) {
    Vector1D v1 = (Vector1D) v;
    return new Vector1D(x + factor * v1.getX());
}
 
Example #26
Source File: Vector2D.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc}
 */
public double distance(Vector<Euclidean2D> p) {
    return distance((Point<Euclidean2D>) p);
}
 
Example #27
Source File: AbstractRegion.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public Location checkPoint(final Vector<S> point) {
    return checkPoint(tree, point);
}
 
Example #28
Source File: NPEfix_00173_s.java    From coming with MIT License 4 votes vote down vote up
/** {@inheritDoc} */
public double getOffset(final Vector<Euclidean2D> point) {
    Vector2D p2 = (Vector2D) point;
    return sin * p2.getX() - cos * p2.getY() + originOffset;
}
 
Example #29
Source File: Vector1D.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc}
 * @deprecated as of 3.3, replaced with {@link #distance(Point)}
 */
@Deprecated
public double distance(Vector<Euclidean1D> p) {
    return distance((Point<Euclidean1D>) p);
}
 
Example #30
Source File: Line.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public Vector1D toSubSpace(final Vector<Euclidean2D> point) {
    Vector2D p2 = (Vector2D) point;
    return new Vector1D(cos * p2.getX() + sin * p2.getY());
}