Package jjil.core

Examples of jjil.core.Vec2


                    (p.getY()*this.mnScale+this.mnOffsetY)/256);
            Point ptNext = cli.getNext().getPos();
            Point posNext = new Point((ptNext.getX()*this.mnScale+this.mnOffsetX)/256,
                    (ptNext.getY()*this.mnScale+this.mnOffsetY)/256);
            Point pt = new Point((int) pos.getX(), (int) pos.getY());
            Vec2 vec = new Vec2((int) (posNext.getX() - pos.getX()),
                    (int) (posNext.getY() - pos.getY()));
            polypts.add(new EdgePt(pt,vec));
        }
        this.add(polypts);
       
View Full Code Here


     * Sets the vector from this EdgePt to the next.
     *
     * @param nextPt the new vector to the next EdgePt
     */
    void setVec(EdgePt nextPt) {
        this.mvNext = new Vec2(this.getPos(), nextPt.getPos());
    }
View Full Code Here

     */
    public Features(List<EdgePts> leps) {
      this.mnComponents = leps.size();
        this.mleps = leps;
        /* find this.mvMean.getX(), this.mvMean.getY() */
        Vec2 Sum = new Vec2(0, 0);
        int LengthSum = 0;
        for (CircularList<EdgePt> OutLine : leps) {
            if (OutLine.size() <= 1) {
                continue;
            }
            CircularList<EdgePt>.CircListIter li = OutLine.circListIterator();
            Point Last = li.getNext().getPos();
            while (li.hasNext()) {
                li.next();
                Point Norm = li.getNext().getPos();
                int n = 1;
                Vec2 Delta = new Vec2(Last, Norm);
                int Length = 0;
                try {
                    Length = Delta.length();
                } catch (jjil.core.Error ex) {
                }
                n = ((Length << 2) + Length + 32) >> 6;
                if (n != 0) {
                    Sum.add(((Last.getX()<<1)+Delta.getX())*Length,
                        ((Last.getY()<<1)+Delta.getY())*Length);
                    LengthSum += Length;
                }
                if (n != 0) {
                    Last = Norm;
                }
View Full Code Here

                Point Norm = new Point(LastX, LastY);
                if (Last == null) {
                    Last = Norm;
                } else {
                    int n = 1;
                    Vec2 Delta = new Vec2(Last, Norm);
                    int Length = 0;
                    try {
                        Length = Delta.length();
                    } catch (jjil.core.Error ex) {
                    }
                    n = ((Length << 2) + Length + 32) >> 6;
                    if (n != 0) {
                        short Theta = mPrecomputeMath.TableLookup(Delta);
                        Vec2 d = Delta.lsh(8).div(n);
                        Vec2 pf = new Vec2(Last).lsh(8).add(d.clone().rsh(1));
                        for (int i = 0; i < n; i++) {
                          // check to see if we're out of static feature
                          // slots
                          if (snFeaturesUsed == MAX_FEATURES) {
                            return;
                          }
                          Feature f = srFeatures[snFeaturesUsed++];
                          f.set((short) (pf.getX() >> 8),
                                    (short) ((pf.getY() >> 8)),
                                    Theta);
                            if (!this.add(f)) {
                                return;
                            }
                            pf.add(d);
                        }
                    }
                    if (n != 0) {              /* Throw away a point that is too close */
                        Last = Norm;
                    }
View Full Code Here

     * Compute the radius of gyration.
     *
     * @param leps the leps
     */
    private void computeRadiusGyration(List<EdgePts> leps) {
        Vec2 vMeanShift = this.mvMean.clone().lsh(8);
        int nBLFeat = 0;
        Vec2 I = new Vec2(0, 0);
        for (CircularList<EdgePt> Outline : leps) {
            if (Outline.size() <= 1) {
                continue;
            }
            Point Last = null;
            for (ListIterator<EdgePt> li = Outline.loopIterator();
                    li.hasNext();) {
                EdgePt Segment = li.next();
                Point Norm = Segment.getPos().clone();
                if (Last == null) {
                    Last = Norm;
                } else {
                    int n = 1;
                    Vec2 Delta = new Vec2(Last, Norm);
                    int Length = 0;
                    try {
                        Length = Delta.length();
                    } catch (jjil.core.Error ex) {
                    }
                    n = ((Length << 2) + Length + 32) >> 6;
                    nBLFeat += n;
                    if (n != 0) {
                        Vec2 d = Delta.lsh(8).div(n);
                        Vec2 pf = new Vec2(Last).lsh(8).add(d.clone().rsh(1)).
                                sub(vMeanShift);
                        long lX = (long) pf.getX() * pf.getX() * n +
                                (long) pf.getX() * d.getX() * n * (n - 1) +
                                (long) d.getX() * d.getX() * n * (n - 1) * (2 * n - 1) / 6;
                        long lY = (long) pf.getY() * pf.getY() * n +
                                (long) pf.getY() * d.getY() * n * (n - 1) +
                                (long) d.getY() * d.getY() * n * (n - 1) * (2 * n - 1) / 6;
                        I.add((int) (lX >> 16), (int) (lY >> 16));
                        Last = Norm;
                    }
                }
View Full Code Here

        this.rprResult = new int[32/RESULT_TABLE_REDUCTION][64][64];
for (int i=0; i<32; i+=RESULT_TABLE_REDUCTION) {
            for (int j=0; j<64; j++) {
//              this.rprResult[i][j] = IntBuffer.allocate(64);
                for (int k=0; k<64; k++) {
                    Vec2 sqrtX = MySqrt2(i<<2, j<<13);
                    Vec2 sqrtY = MySqrt2(i<<2, k<<13);
                    this.rprResult[i/RESULT_TABLE_REDUCTION][j][k] =
                            PairVec2Int(ClipRadius(sqrtX, sqrtY));
//                    this.rprResult[i][j][k] =
//                            ClipRadius(sqrtX, sqrtY);
                }
View Full Code Here

        BitN = (short) (LastCarry + 1);
        LastCarry = (short) ((BitN & 2) > 1? 1: 0);
        BitN = (short) (BitN & 1);

        if (BitN == 1) {
            Rx = new Vec2(RadiusGyrMinMan, RadiusGyrMinExp);
        }

        AM = RadiusGyrMinMan;
        AE = RadiusGyrMinExp;
        BM = (short) Ry.getX();
        BE = (short) Ry.getY();
        LastCarry = 1;
        while ((AM != 0) || (BM != 0)) {
            if (AE > BE) {
                BitN = (short) (LastCarry + (AM & 1) + 1);
                AM >>= 1;
                AE = (short) ((AE==0)?255:AE-1);
            } else if (AE < BE) {
                BitN = (short) (LastCarry + ((~(BM & 1))&1));
                BM >>= 1;
                BE = (short) ((BE==0)?255:BE-1);
            } else {                       /* AE == BE */
                BitN = (short) (LastCarry + (AM & 1) + ((~(BM & 1))&1));
                AM >>= 1;
                BM >>= 1;
                AE = (short) ((AE==0)?255:AE-1);
                BE = (short) ((BE==0)?255:BE-1);
            }
            LastCarry = (short) ((BitN & 2) > 1? 1: 0);
            BitN = (short) (BitN & 1);
        }
        BitN = (short) (LastCarry + 1);
        LastCarry = (short) ((BitN & 2) > 1? 1 : 0);
        BitN = (short) (BitN & 1);

        if (BitN == 1) {
            Ry = new Vec2(RadiusGyrMinMan, RadiusGyrMinExp);
        }

        AM = RadiusGyrMaxMan;
        AE = RadiusGyrMaxExp;
        BM = (short) Rx.getX();
        BE = (short) Rx.getY();
        LastCarry = 1;
        while ((AM != 0) || (BM != 0)) {
            if (AE > BE) {
                BitN = (short) (LastCarry + (AM & 1) + 1);
                AM >>= 1;
                AE = (short) ((AE==0)?255:AE-1);
            } else if (AE < BE) {
                BitN = (short) (LastCarry + ((~(BM & 1))&1));
                BM >>= 1;
                BE = (short) ((BE==0)?255:BE-1);
            } else {                       /* AE == BE */
                BitN = (short) (LastCarry + (AM & 1) + ((~(BM & 1))&1));
                AM >>= 1;
                BM >>= 1;
                AE = (short) ((AE==0)?255:AE-1);
                BE = (short) ((BE==0)?255:BE-1);
            }
            LastCarry = (short) ((BitN & 2) > 1? 1 : 0);
            BitN = (short) (BitN & 1);
        }
        BitN = (short) (LastCarry + 1);
        LastCarry = (short) ((BitN & 2) > 1? 1 : 0);
        BitN = (short) (BitN & 1);

        if (BitN == 1) {
            RxInvLarge = 1;
        } else {
            RxInvLarge = 0;
        }
        AM = (short) Ry.getX();
        AE = (short) Ry.getY();
        BM = RadiusGyrMaxMan;
        BE = RadiusGyrMaxExp;
        LastCarry = 1;
        while ((AM != 0) || (BM != 0)) {
            if (AE > BE) {
                BitN = (short) (LastCarry + (AM & 1) + 1);
                AM >>= 1;
                AE = (short) ((AE==0)?255:AE-1);
            } else if (AE < BE) {
                BitN = (short) (LastCarry + ((~(BM & 1))&1));
                BM >>= 1;
                BE = (short) ((BE==0)?255:BE-1);
            } else {                       /* AE == BE */
                BitN = (short) (LastCarry + (AM & 1) + ((~(BM & 1))&1));
                AM >>= 1;
                BM >>= 1;
                AE = (short) ((AE==0)?255:AE-1);
                BE = (short) ((BE==0)?255:BE-1);
            }
            LastCarry = (short) ((BitN & 2) > 1? 1 : 0);
            BitN = (short) (BitN & 1);
        }
        BitN = (short) (LastCarry + 1);
        LastCarry = (short) ((BitN & 2) > 1? 1 : 0);
        BitN = (short) (BitN & 1);

        if (BitN == 1) {
            RyInvSmall = 1;
        } else {
            RyInvSmall = 0;
        }
        if (RxInvLarge != 0 && RyInvSmall != 0) {
            Ry = new Vec2(RadiusGyrMaxMan, RadiusGyrMaxExp);
        }
        return new Pair(Rx, Ry);
    }
View Full Code Here

     *
     * @return the vec2
     */
    private static Vec2 MySqrt2(int N, int I) {
        if (N == 0 || I == 0) {
            return new Vec2(0,0);
        }
        long N2 = N * 41943;

        short k = 9;
        while ((N2 & 0xc0000000) == 0) {
            N2 <<= 2;
            k += 1;
        }

        while ((I & 0xc0000000) == 0) {
            I <<= 2;
            k -= 1;
        }

        if (((N2 & 0x80000000) == 0) && ((I & 0x80000000) == 0)) {
            N2 <<= 1;
            I <<= 1;
        }

        N2 &= 0xffff0000;
        I >>>= 14;
        int Ratio = (int) (N2 / I);

        short BitLocation = 128;
        int SqRoot = 0;
        do {
            int Square = (SqRoot | BitLocation) * (SqRoot | BitLocation);
            if (Square <= Ratio) {
                SqRoot |= BitLocation;
            }
            BitLocation >>>= 1;
        } while (BitLocation != 0);

        if (k < 0) {
            return new Vec2(255, 0);
        } else {
            return new Vec2(SqRoot, k);
        }
    }
View Full Code Here

    private Pair<Vec2,Vec2> Int2PairVec(int l) {
        short s1 = (short) ((l >>> 24));
        short s2 = (short) (((l << 8) >>> 24));
        short s3 = (short) (((l << 16) >>> 24));
        short s4 = (short) (((l << 24) >>> 24));
        return new Pair<Vec2,Vec2>(new Vec2(s1,s2), new Vec2(s3,s4));
    }
View Full Code Here

     */
    EdgePts(CircularList<Point> lpt, TimeTracker tt) {
      this.mTimeTracker = tt;
        CircularList<Point>.CircListIter cli = lpt.circListIterator();
        Point ptPrev = null;
        Vec2 vPrev = null;
        int nRunLength = 0;
        /* for each point in the list */
        while (cli.hasNext() && snEdgePtsUsed < MAX_EDGEPTS-1) {
            Point pt = cli.next();
            Point ptNext = cli.getNext();
            /* get vector to next point */
            Vec2 v = pt.diff(ptNext);
            /* check for start of list */
            if (vPrev == null) {
              /* initialize bounding box */
                this.rectBounds = new JessRect(pt);
                /* initialize previous point, run length, and previous vector */
 
View Full Code Here

TOP

Related Classes of jjil.core.Vec2

Copyright © 2018 www.massapicom. 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.