Examples of Vec2


Examples of jjil.core.Vec2

        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

Examples of jjil.core.Vec2

     *
     * @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

Examples of jjil.core.Vec2

    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

Examples of jjil.core.Vec2

     */
    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

Examples of jjil.core.Vec2

        if (cliStart.getNext() == cliEnd.getPrevious()) {
            return 0;
        }
        // vecLine is the direction from the ending point to
        // the starting point
         Vec2 vecLine = cliEnd.getNext().getPos().diff(cliStart.getNext().getPos());
        // check for starting and ending points the same
        if (vecLine.getX() == 0 && vecLine.getY() == 0) {
          // measure from curve direction at start
            vecLine = cliStart.getPrevious().getVec();
        }
        // maxPerp is the max distance from the line to the current point
        int maxPerp = Integer.MIN_VALUE;
        CircListIter cli = cliStart.clone();
        cli.next();
        CircListIter cliMaxPoint = cli;
        this.mvSum.setXY(0, 0);
        // for each point from start to end
        while (cli.getNext() != cliEnd.getNext()) {
          // get the point
            this.mvSum.add(cli.next().getVec());
            // perp is the magnitude of the cross product
            // of vec (current position) x vecLine (line)
            // which is the distance of vec to the line
            // (times the length of vecLine which doesn't change)
            int perp = this.mvSum.crossMag(vecLine);
            perp *= perp;
            // if we're further from the line than we've
            // been before
            if (perp > maxPerp) {
                maxPerp = perp;
                cliMaxPoint = cli.clone();
                cliMaxPoint.previous();
            }
        };
        int vLen = 0;
        try {
          vLen = vecLine.length();
        } catch (jjil.core.Error er) {
         
        }
        // check to see if we should split again
        // remember maxPerp = | vLen | * (max perpendicular distance to vecLine)
View Full Code Here

Examples of jjil.core.Vec2

        do {
            if (fixed_count <= 3) {
                break;                     //already too few

            }
            Vec2 d12vec = edgefix1.getPos().diff(edgefix2.getPos());
            int d12 = d12vec.lengthSqr();
            if (d12 <= gapmin) {
                Vec2 d01vec = edgefix0.getPos().diff(edgefix1.getPos());
                int d01 = d01vec.lengthSqr();
                Vec2 d23vec = edgefix2.getPos().diff(edgefix3.getPos());
                int d23 = d23vec.lengthSqr();
                if (d01 > d23) {
                    edgefix2.resetFixed();
                    fixed_count--;
                } else {
                    edgefix1.resetFixed();
View Full Code Here

Examples of org.filsa.nikujaga.pong.math.Vec2

  public Vec2 pos = new Vec2();
  public Vec2 dir = new Vec2(1,1);
  public int size = 20;
 
  public Ball () {
    pos = new Vec2(1, 0);
  }
View Full Code Here

Examples of org.jbox2d.common.Vec2

    private static void render() {
        glClear(GL_COLOR_BUFFER_BIT);
        for (Body body : bodies) {
            if (body.getType() == BodyType.DYNAMIC) {
                glPushMatrix();
                Vec2 bodyPosition = body.getPosition().mul(30);
                glTranslatef(bodyPosition.x, bodyPosition.y, 0);
                glRotated(Math.toDegrees(body.getAngle()), 0, 0, 1);
                glRectf(-0.75f * 30, -0.75f * 30, 0.75f * 30, 0.75f * 30);
                glPopMatrix();
            }
View Full Code Here

Examples of org.jbox2d.common.Vec2

    private static void input() {
        while (Keyboard.next()) {
            if (Keyboard.getEventKeyState()) {
                switch (Keyboard.getEventKey()) {
                    case Keyboard.KEY_C:
                        Vec2 bodyPosition = new Vec2(Mouse.getX(), Mouse.getY()).mul(0.5f).mul(1 / 30f);
                        BodyDef boxDef = new BodyDef();
                        boxDef.position.set(bodyPosition);
                        boxDef.type = BodyType.DYNAMIC;
                        PolygonShape boxShape = new PolygonShape();
                        boxShape.setAsBox(0.75f, 0.75f);
                        Body box = world.createBody(boxDef);
                        FixtureDef boxFixture = new FixtureDef();
                        boxFixture.density = 0.1f;
                        boxFixture.shape = boxShape;
                        box.createFixture(boxFixture);
                        bodies.add(box);
                        break;
                }
            }
        }
        for (Body body : bodies) {
            if (body.getType() == BodyType.DYNAMIC) {
                if (Keyboard.isKeyDown(Keyboard.KEY_A) && !Keyboard.isKeyDown(Keyboard.KEY_D)) {
                    body.applyAngularImpulse(+0.01f);
                } else if (Keyboard.isKeyDown(Keyboard.KEY_D) && !Keyboard.isKeyDown(Keyboard.KEY_A)) {
                    body.applyAngularImpulse(-0.01f);
                }
                if (Mouse.isButtonDown(0)) {
                    Vec2 mousePosition = new Vec2(Mouse.getX(), Mouse.getY()).mul(0.5f).mul(1 / 30f);
                    Vec2 bodyPosition = body.getPosition();
                    Vec2 force = mousePosition.sub(bodyPosition);
                    body.applyForce(force, body.getPosition());
                }
            }
        }
    }
View Full Code Here

Examples of org.jbox2d.common.Vec2

    private static void render() {
        glClear(GL_COLOR_BUFFER_BIT);
        for (Body body : bodies) {
            if (body.getType() == BodyType.DYNAMIC) {
                glPushMatrix();
                Vec2 bodyPosition = body.getPosition().mul(30);
                glTranslatef(bodyPosition.x, bodyPosition.y, 0);
                glRotated(Math.toDegrees(body.getAngle()), 0, 0, 1);
                glRectf(-0.75f * 30, -0.75f * 30, 0.75f * 30, 0.75f * 30);
                glPopMatrix();
            }
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.