Examples of Vector2d


Examples of javax.vecmath.Vector2d

  }

  private void renderCurrentRoboter(Graphics g) {
    LightSensor leftLightSensor = roboter.getLeftLightSensor();
    LightSensor rightLightSensor = roboter.getRightLightSensor();
    Vector2d directionVector = roboter.getDirection();
    if (renderRoboter) {
      g.setColor(color);
      SlickRenderUtils.fillCircle(g, roboter.getX(), roboter.getY(), 3);
      if (selected) {
        g.setColor(Color.yellow);
        SlickRenderUtils.drawCircle(g, roboter.getX(), roboter.getY(), 4);
        SlickRenderUtils.drawCircle(g, roboter.getX(), roboter.getY(), 5);
        SlickRenderUtils.drawCircle(g, roboter.getX(), roboter.getY(), 6);
      }
      g.setColor(color);
      double currentDirectionPointX = roboter.getX() + directionPointLength * directionVector.getX();
      double currentDirectionPointY = roboter.getY() + directionPointLength * directionVector.getY();
      g.drawLine((float) roboter.getX(), (float) roboter.getY(), (float) currentDirectionPointX, (float) currentDirectionPointY);

      drawMotor(g, roboter.getLeftMotor());
      drawMotor(g, roboter.getRightMotor());

View Full Code Here

Examples of net.edzard.kinetic.Vector2d

    stage.add(layer);
  }

  public void testCreationZOrder() {
    for (int i=0; i < 3; ++i) {
      Circle c = Kinetic.createCircle(new Vector2d(10,10), 5);
      layer.add(c);
      assertEquals(i, c.getZIndex())
    }
  } 
View Full Code Here

Examples of net.sf.fysix.math.Vector2d

 
  public void addObject(WorldObject wo, boolean fastObject) {
    BodyDef def = wo.getBodyDef();
    Body body = jbox2dWorld.createDynamicBody(def);
    body.setBullet(fastObject);
    Vector2d vel = wo.getVelocity();
    body.setLinearVelocity(new Vec2((float) vel.getX(), (float) vel.getY()));
    for (ShapeDef sd : wo.getShapeDefs()) {
      body.createShape(sd);
    }
    // TODO Use body.setMassFromShapes() for more realism
    wo.setBody(body);
View Full Code Here

Examples of net.wigis.graph.dnv.utilities.Vector2D

    float globalMinX = GraphFunctions.getMinXPosition( subgraph.getSuperGraph(), level, true );
    float globalMaxX = GraphFunctions.getMaxXPosition( subgraph.getSuperGraph(), level, true );
    float globalMinY = GraphFunctions.getMinYPosition( subgraph.getSuperGraph(), level, true );
    float globalMaxY = GraphFunctions.getMaxYPosition( subgraph.getSuperGraph(), level, true );

    Vector2D bottomLeft = new Vector2D( globalMinX, globalMaxY );
    Vector2D bottomRight = new Vector2D( globalMaxX, globalMaxY );
    Vector2D topLeft = new Vector2D( globalMinX, globalMinY );

    Vector2D bottomLeftScreen = ImageRenderer.transformPosition( pb, bottomLeft );
    Vector2D bottomRightScreen = ImageRenderer.transformPosition( pb, bottomRight );
    Vector2D topLeftScreen = ImageRenderer.transformPosition( pb, topLeft );

    g2d.setColor( Color.black );
    g2d.setStroke( new BasicStroke( 1 ) );
    Vector3D color = new Vector3D( 0, 0, 0 );
    Vector3D outlineColor = new Vector3D( 1, 1, 1 );

    // X-axis
    g2d.drawLine( (int)bottomLeftScreen.getX(), (int)bottomLeftScreen.getY(), (int)bottomRightScreen.getX() + 20, (int)bottomRightScreen.getY() );
    Vector2D tempPos = new Vector2D( bottomLeft );
    Vector2D tempPosScreen = new Vector2D( bottomLeftScreen );
    int numberOfTicks = 5;
    float axisTickLength = ( bottomRight.getX() - bottomLeft.getX() ) / numberOfTicks;
    float axisTickLengthScreen = ( bottomRightScreen.getX() - bottomLeftScreen.getX() ) / numberOfTicks;
    for( int i = 0; i <= numberOfTicks; i++ )
    {
      g2d.drawLine( (int)tempPosScreen.getX(), (int)tempPosScreen.getY(), (int)tempPosScreen.getX(), (int)tempPosScreen.getY() + 10 );
      Text text = new Text( "" + ( Math.round( tempPos.getX() * 1000.0 ) / 1000.0 ), new Vector2D( tempPosScreen.getX(),
          tempPosScreen.getY() + 15 ), outlineColor, color, 10, false, true, false, false, false, false, true );
      text.draw( g2d, pb, minXPercent, maxXPercent, minYPercent, maxYPercent, globalMinX, globalMaxX, globalMinY, globalMaxY,
          nodeWidth, height, overview );
      tempPos.add( axisTickLength, 0 );
      tempPosScreen.add( axisTickLengthScreen, 0 );
    }

    // Y-axis
    g2d.drawLine( (int)bottomLeftScreen.getX(), (int)bottomLeftScreen.getY(), (int)topLeftScreen.getX(), (int)topLeftScreen.getY() );
    tempPos.set( bottomLeft );
    tempPosScreen.set( bottomLeftScreen );
    axisTickLength = ( topLeft.getY() - bottomLeft.getY() ) / numberOfTicks;
    axisTickLengthScreen = ( topLeftScreen.getY() - bottomLeftScreen.getY() ) / numberOfTicks;
    for( int i = 0; i <= numberOfTicks; i++ )
    {
      g2d.drawLine( (int)tempPosScreen.getX(), (int)tempPosScreen.getY(), (int)tempPosScreen.getX() - 10, (int)tempPosScreen.getY() );
      Text text = new Text( "" + ( Math.round( tempPos.getY() * 1000.0 ) / 1000.0 ), new Vector2D( tempPosScreen.getX() - 25,
          tempPosScreen.getY() ), outlineColor, color, 10, false, true, false, false, false, false, true );
      text.draw( g2d, pb, minXPercent, maxXPercent, minYPercent, maxYPercent, globalMinX, globalMaxX, globalMinY, globalMaxY,
          nodeWidth, height, overview );
      tempPos.add( 0, axisTickLength );
      tempPosScreen.add( 0, axisTickLengthScreen );
    }
  }
View Full Code Here

Examples of org.antlr.xjlib.appkit.gview.base.Vector2D

        }

        float cx = x1-ctrl_offset;
        float ax0 = cx-arc_offset;

        Vector2D a = new Vector2D(cx, y0);
        Vector2D b = new Vector2D(x1, y1);
        Vector2D z = a.add(b.sub(a).setLength(Math.abs(arc_offset)));

        drawLine(x0+start_offset, y0, ax0, y0);
        drawSpline((float)z.x, (float)z.y, x1, y1, 0, end_offset, 0, arrow);

        QuadCurve2D.Float quad = new QuadCurve2D.Float();
View Full Code Here

Examples of org.apache.commons.math3.geometry.euclidean.twod.Vector2D

        }

        // build upper hull
        final List<Vector2D> upperHull = new ArrayList<Vector2D>();
        for (int idx = pointsSortedByXAxis.size() - 1; idx >= 0; idx--) {
            final Vector2D p = pointsSortedByXAxis.get(idx);
            updateHull(p, upperHull);
        }

        // concatenate the lower and upper hulls
        // the last point of each list is omitted as it is repeated at the beginning of the other list
View Full Code Here

Examples of org.apache.commons.math3.geometry.euclidean.twod.Vector2D

    private void updateHull(final Vector2D point, final List<Vector2D> hull) {
        final double tolerance = getTolerance();

        if (hull.size() == 1) {
            // ensure that we do not add an identical point
            final Vector2D p1 = hull.get(0);
            if (p1.distance(point) < tolerance) {
                return;
            }
        }

        while (hull.size() >= 2) {
            final int size = hull.size();
            final Vector2D p1 = hull.get(size - 2);
            final Vector2D p2 = hull.get(size - 1);

            final double offset = new Line(p1, p2, tolerance).getOffset(point);
            if (FastMath.abs(offset) < tolerance) {
                // the point is collinear to the line (p1, p2)

                final double distanceToCurrent = p1.distance(point);
                if (distanceToCurrent < tolerance || p2.distance(point) < tolerance) {
                    // the point is assumed to be identical to either p1 or p2
                    return;
                }

                final double distanceToLast = p1.distance(p2);
View Full Code Here

Examples of org.apache.commons.math3.geometry.euclidean.twod.Vector2D

     */
    public static Collection<Vector2D> reducePoints(final Collection<Vector2D> points) {

        // find the leftmost point
        int size = 0;
        Vector2D minX = null;
        Vector2D maxX = null;
        Vector2D minY = null;
        Vector2D maxY = null;
        for (Vector2D p : points) {
            if (minX == null || p.getX() < minX.getX()) {
                minX = p;
            }
            if (maxX == null || p.getX() > maxX.getX()) {
                maxX = p;
            }
            if (minY == null || p.getY() < minY.getY()) {
                minY = p;
            }
            if (maxY == null || p.getY() > maxY.getY()) {
                maxY = p;
            }
            size++;
        }

View Full Code Here

Examples of org.apache.commons.math3.geometry.euclidean.twod.Vector2D

     * @return {@code true} if the point is inside the quadrilateral, {@code false} otherwise
     */
    private static boolean insideQuadrilateral(final Vector2D point,
                                               final List<Vector2D> quadrilateralPoints) {

        Vector2D p1 = quadrilateralPoints.get(0);
        Vector2D p2 = quadrilateralPoints.get(1);

        if (point.equals(p1) || point.equals(p2)) {
            return true;
        }

View Full Code Here

Examples of org.apache.commons.math3.geometry.euclidean.twod.Vector2D

            return true;
        }

        int sign = 0;
        for (int i = 0; i < hullVertices.length; i++) {
            final Vector2D p1 = hullVertices[i == 0 ? hullVertices.length - 1 : i - 1];
            final Vector2D p2 = hullVertices[i];
            final Vector2D p3 = hullVertices[i == hullVertices.length - 1 ? 0 : i + 1];

            final Vector2D d1 = p2.subtract(p1);
            final Vector2D d2 = p3.subtract(p2);

            final double crossProduct = MathArrays.linearCombination(d1.getX(), d2.getY(), -d1.getY(), d2.getX());
            final int cmp = Precision.compareTo(crossProduct, 0.0, tolerance);
            // in case of collinear points the cross product will be zero
            if (cmp != 0.0) {
                if (sign != 0.0 && cmp != sign) {
                    return false;
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.