Examples of GVector


Examples of javax.vecmath.GVector

     * @param eps the tolerable error (eg .0000001)
     */
    public static GVector conjugateGradientSolve( GMatrix matrix, GVector b,
                                                  GVector initialGuess, double eps ) {

        GVector x = new GVector( initialGuess );
        GVector tempv = new GVector( initialGuess );
        tempv.mul( matrix, initialGuess );
        GVector bb = new GVector( b );
        bb.sub( tempv );
        GVector r = new GVector( bb );
        GVector p = new GVector( r );
        GVector xnew = new GVector( p );
        GVector rnew = new GVector( p );
        GVector pnew = new GVector( p );
        GVector matrixMultp = new GVector( p );
        GMatrix matrixInverse = new GMatrix( matrix );
        matrixInverse.invert();
        double error, norm;
        int iteration = 0;

        do {
            matrixMultp.mul( matrix, p );
            double lambda = (r.dot( p ) / p.dot( matrixMultp ));
            xnew.scaleAdd( lambda, p, x );
            rnew.scaleAdd( -lambda, matrixMultp, r );
            double alpha = -(rnew.dot( matrixMultp ) / p.dot( matrixMultp));
            pnew.scaleAdd( alpha, p, rnew );
View Full Code Here

Examples of javax.vecmath.GVector

    double ua = uaNum / denom;
    double ub = ubNum / denom;

    if (clamp(ua, 0f, 1f) != ua || clamp(ub, 0f, 1f) != ub)
      return null;
    GVector v=new GVector(new double[] {a.A.getPosition().x,a.A.getPosition().y});
    GVector d=new GVector(new double[] {a.B.getPosition().x,a.B.getPosition().y});
    d.sub(v);
    d.scale(ua);
    d.add(v);
    return new Coordinate(d.getElement(0),d.getElement(1));   
  }
View Full Code Here

Examples of javax.vecmath.GVector

      return shapeVerts;

    //otherwise we can find our mutually visible vertex to split the polygon
   
    Coordinate I = rightMostHoleVertex.getPosition();
    GVector i=new GVector(new double[] {I.x,I.y});
    i.add(new GVector(new double[] {closestPoint.floatValue(),0.0}));
   
    Vertex P = (closestSegment.A.getPosition().x > closestSegment.B.getPosition().x)
      ? closestSegment.A
      : closestSegment.B;
   
    //construct triangle MIP
    Triangle mip = new Triangle(rightMostHoleVertex, new Vertex(I, 1), P);
    //see if any of the reflex vertices lie inside of the MIP triangle
    ArrayList interiorReflexVertices = new ArrayList();
    for (int count=0;count<reflexVertices.size();count++) {
      Vertex v=(Vertex)reflexVertices.get(count);
      if (mip.ContainsPoint(v))
        interiorReflexVertices.add(v);
    }
   
    //if there are any interior reflex vertices, find the one that, when connected
    //to our rightMostHoleVertex, forms the line closest to Vector2.UnitX
    if (interiorReflexVertices.size() > 0)
    {
      float closestDot = -1f;
      for (int count=0;count<interiorReflexVertices.size();count++)
      {
        Vertex v=(Vertex)interiorReflexVertices.get(count);
        GVector n=new GVector(new double[] {v.getPosition().x,v.getPosition().y});
        n.sub(new GVector(new double[] {rightMostHoleVertex.getPosition().x,rightMostHoleVertex.getPosition().y}));
        n.normalize();
        GVector m=new GVector(new double[] {1.0,0.0});
        float dot=(float)m.dot(n);
       

        //if this line is the closest we've found
        if (dot > closestDot)
        {
View Full Code Here

Examples of javax.vecmath.GVector

    Vertex p = (Vertex)polygonVertices.get(polygonVertices.indexOf(c) - 1);
    Vertex n = (Vertex)polygonVertices.get(polygonVertices.indexOf(c) + 1);
    Coordinate cc=c.getPosition();
    Coordinate pc=p.getPosition();
    Coordinate nc=n.getPosition();
    GVector d1=new GVector(new double[] {cc.x,cc.y});
    d1.sub(new GVector(new double[] {pc.x,pc.y}));
    d1.normalize();
   
    GVector d2=new GVector(new double[] {nc.x,nc.y});
    d2.sub(new GVector(new double[] {cc.x,cc.y}));
    d2.normalize();
   
   
    GVector n2=new GVector(new double[] {-d2.getElement(1),d2.getElement(0)});
    return d1.dot(n2)<=0.0;
  }
View Full Code Here

Examples of javax.vecmath.GVector

    for (int i = 1; i < vertices.getNumPoints(); i++)
    {
      Coordinate p2 = vertices.getCoordinateN(i);
      Coordinate p3 = vertices.getCoordinateN((i + 1) % vertices.getNumPoints());
      GVector e1=new GVector(new double[] {p1.x,p1.y});
      e1.sub(new GVector(new double[] {p2.x,p2.y}));
      GVector e2=new GVector(new double[] {p3.x,p3.y});
      e2.sub(new GVector(new double[] {p2.x,p2.y}));
     

      if (e1.getElement(0)* e2.getElement(1) - e1.getElement(1) * e2.getElement(0) >= 0)
        clockWiseCount++;
      else
        counterClockWiseCount++;

      p1 = p2;
View Full Code Here

Examples of javax.vecmath.GVector

        int[] pixels = new int[width * height];
        PixelGrabber pg = new PixelGrabber(image, x, y, width, height, pixels, 0, width);
        try { pg.grabPixels(); }
        catch(InterruptedException e) { throw new RuntimeException(e); }
       
        GVector data = new GVector(3 * pixels.length);
        for(int i = 0; i < pixels.length; i++) {
            int red   = (pixels[i] >> 16) & 0xff;
            int green = (pixels[i] >>  8) & 0xff;
            int blue  = (pixels[i]      ) & 0xff;
            data.setElement(3 * i    , red);
            data.setElement(3 * i + 1, green);
            data.setElement(3 * i + 2, blue);
        }
       
        return data;
    }
View Full Code Here

Examples of javax.vecmath.GVector

          double kElem = k.getElement(i, i);
            k.setElement(i, i, kElem - lambda);
        }
       
        k.invert();
        GVector c = new GVector(numPoints);
        c.mul(k, values);
       
        return new Representer(kernel, data, c);
    }
View Full Code Here

Examples of javax.vecmath.GVector

     * evaluated for the data points in columns i and j in the data.
     */
    public static GMatrix kernelMatrix(GMatrix data, Kernel kernel) {
        int rows = data.getNumRow(), cols = data.getNumCol();
        GMatrix k = new GMatrix(cols, cols);
        GVector x1 = new GVector(rows);
        GVector x2 = new GVector(rows);
       
        // kernels are symmetric, so we only need calculate
        // every {i, j} combination, not permutation.
        for(int i = 0; i < cols; i++) {
            data.getColumn(i, x1);
View Full Code Here

Examples of javax.vecmath.GVector

            throw new MismatchedSizeException();
        }
       
        this.kernel = kernel;
        this.points = new GVector[data.getNumCol()];
        this.coeffs = new GVector(coeffs);
        this.copyCoeffs = new GVector(coeffs);
       
        for(int i = 0; i < data.getNumCol(); i++) {
            this.points[i] = new GVector(data.getNumRow());
            data.getColumn(i, points[i]);
        }
    }
View Full Code Here

Examples of javax.vecmath.GVector

     */
    public static GVector mapCols(Function fun, GMatrix points) {
        if (fun == nullthrow new NullPointerException("fun");       
        int rows = points.getNumRow();
        int cols = points.getNumCol();
        GVector values = new GVector(cols);
       
        for(int i = 0; i < cols; i++) {
            GVector x = new GVector(rows);
            points.getColumn(i, x);
            values.setElement(i, fun.eval(x));
        }
       
        return values;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.