Package javax.vecmath

Examples of javax.vecmath.Vector2d


            change_.normalize();
            frictionalForce = -particles_[i].mass * params.getDynamicFriction();
            change_.scale( frictionalForce );

            // eliminate the frictional force in the spinal direction
            Vector2d spineDir = segment.getSpinalDirection();
            double dot = spineDir.dot( change_ );
            if ( dot < 0 ) {
                // then the velocity vector is going at least partially backwards
                // remove the backwards component.
                vel_.set( spineDir );
                vel_.scale( dot );
View Full Code Here


        g2.setColor(COLOR);

        double cwLeverLength = lever_.getCounterWeightLeverLength();
        double cos = SCALE_FACTOR * cwLeverLength* Math.cos(angle_);
        double sin = SCALE_FACTOR * cwLeverLength * Math.sin(angle_);
        Vector2d attachPt = new Vector2d(STRUT_BASE_X + sin, (int) ( -SCALE_FACTOR * height_) - cos);


        g2.drawLine((int) (scale * attachPt.x),
                    (int) (BASE_Y + scale * attachPt.y),
                    (int) (scale * attachPt.x),
 
View Full Code Here

        }
        force_.set(force);

        acceleration_.set(force);
        acceleration_.scale( 1.0 / getMass());
        Vector2d deltaVelocity = new Vector2d(acceleration_);
        deltaVelocity.scale(timeStep);
        velocity_.add(deltaVelocity);

        position_.set(position_.x + SCALE_FACTOR * timeStep * velocity_.x,
                      position_.y + SCALE_FACTOR * timeStep * velocity_.y);
        if (isOnRamp() && position_.y < (-4)) {
View Full Code Here

        return counterWeightLeverLength_ + slingLeverLength_;
    }

    // @@ make constant to improve perf?
    public Vector2d getFulcrumPosition() {
        return new Vector2d(STRUT_BASE_X, (int) (-SCALE_FACTOR * height_));
    }
View Full Code Here

    public void render(Graphics2D g2, double scale) {

        g2.setStroke(LEVER_STROKE);
        g2.setColor(LEVER_COLOR);

        Vector2d fulcrumPos = getFulcrumPosition();

        double cos = SCALE_FACTOR * Math.cos(angle_);
        double sin = SCALE_FACTOR * Math.sin(angle_);

        g2.drawLine((int) (scale * (fulcrumPos.x + sin * counterWeightLeverLength_)),
 
View Full Code Here

        length_ = slingLength;
        lever_ = lever;
        releaseAngle_ = releaseAngle;
        projectile_ = p;

        Vector2d attachPt = getHookPosition();
        p.setX(attachPt.x + SCALE_FACTOR * length_);
        p.setY(attachPt.y - SCALE_FACTOR * p.getRadius());
    }
View Full Code Here

    public Vector2d getHookPosition() {
        double leverLength = lever_.getSlingLeverLength();
        double cos = SCALE_FACTOR * leverLength * Math.cos(angle_);
        double sin = SCALE_FACTOR * leverLength * Math.sin(angle_);
        Vector2d attachPt = new Vector2d(STRUT_BASE_X - sin, (int) (-SCALE_FACTOR * height_) + cos);
        return attachPt;
    }
View Full Code Here

        Vector2d attachPt = new Vector2d(STRUT_BASE_X - sin, (int) (-SCALE_FACTOR * height_) + cos);
        return attachPt;
    }

    public Vector2d getProjectileAttachPoint() {
        Vector2d attachPt = getHookPosition();
        Vector2d dir = new Vector2d(projectile_.getX()-attachPt.x, projectile_.getY()-attachPt.y);
        dir.normalize();
        dir.scale(SCALE_FACTOR * length_);
        attachPt.add(dir);
        return attachPt;
    }
View Full Code Here

        // + "  slingAngleWithHorz("+ slingAngleWithHorz+") =  "+(leverAngleWithHorz + slingAngleWithHorz));
        return  -(slingAngleWithHorz - leverAngleWithHorz);
    }

    public double getAngleWithHorz() {
        Vector2d hookPos = getHookPosition();
        double deltaY = projectile_.getY() - hookPos.y;
        double deltaX = projectile_.getX() - hookPos.x;

        double angle = atan(deltaY / deltaX);
View Full Code Here

    public void render(Graphics2D g2, double scale) {

        g2.setStroke(STROKE);
        g2.setColor(COLOR);

        Vector2d attachPt = getHookPosition();
        Vector2d projectileAttachPt = getProjectileAttachPoint();

        g2.drawLine((int) (scale * attachPt.x),
                    (int) (BASE_Y +  scale * attachPt.y),
                    (int) (scale * projectileAttachPt.x),
                    (int) (BASE_Y + scale * projectileAttachPt.y));
 
View Full Code Here

TOP

Related Classes of javax.vecmath.Vector2d

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.