Package net.wigis.graph.dnv.utilities

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


  /**
   * Store current position.
   */
  public void storeCurrentPosition()
  {
    displayPosition = new Vector2D( position );
    originalPosition = new Vector2D( position );
  }
View Full Code Here


    position.setX( x );
    position.setY( y );

    if( originalPosition == null )
      originalPosition = new Vector2D( position );

    // handlePreviousPosition();
  }
View Full Code Here

   * @param recursive
   *            the recursive
   */
  public void reposition( boolean recursive )
  {
    Vector2D newPos = new Vector2D();
    List<DNVNode> subNodes = subGraph.getNodesList();
    for( int i = 0; i < subNodes.size(); i++ )
    {
      newPos.add( subNodes.get( i ).getPosition() );
    }

    newPos.dotProduct( 1.0f / (float)subNodes.size() );
    setPosition( newPos );

    if( recursive && parentNode != null )
      parentNode.reposition( recursive );

    if( originalPosition == null )
      originalPosition = new Vector2D( position );
  }
View Full Code Here

    float x_pos = 0;// Math.cos( radians );// * bigRadius;

    // z_pos = (float)Math.cos( bigRadians ) * bigRadius;
    y_pos += Math.sin( bigRadians ) * bigRadius;

    Vector2D difference = new Vector2D( -position.getX(), -position.getY() );

    // if( level < maxLevel )
    setPosition( center.getX() + x_pos, center.getY() + y_pos );

    difference.add( position );

    if( placeSubNodes )
    {
      List<DNVNode> subNodes = subGraph.getNodesList();
      for( int i = 0; i < subNodes.size(); i++ )
View Full Code Here

   * @return the overall area
   */
  public void getOverallArea( Vector2D maxValues, Vector2D minValues, boolean recursive )
  {
    DNVNode tempNode;
    Vector2D tempPosition;
    List<DNVNode> subNodes = subGraph.getNodesList();
    for( int i = 0; i < subNodes.size(); i++ )
    {
      tempNode = subNodes.get( i );
      tempPosition = tempNode.getPosition();
      if( tempPosition.getX() > maxValues.getX() )
        maxValues.setX( tempPosition.getX() );
      if( tempPosition.getY() > maxValues.getY() )
        maxValues.setY( tempPosition.getY() );

      if( tempPosition.getX() < minValues.getX() )
        minValues.setX( tempPosition.getX() );
      if( tempPosition.getY() < minValues.getY() )
        minValues.setY( tempPosition.getY() );

      if( recursive )
        tempNode.getOverallArea( maxValues, minValues, recursive );
    }
  }
View Full Code Here

   *
   * @return the overall area
   */
  public Vector2D getOverallArea()
  {
    Vector2D area = new Vector2D();
    Vector2D maxValues = new Vector2D( Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY );
    Vector2D minValues = new Vector2D( Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY );

    getOverallArea( maxValues, minValues, true );

    area.set( maxValues.subtract( minValues ) );

View Full Code Here

  public void updateEdgelengthsAndMass( Map<Integer, Float> processedEdges, boolean updateSubNodes )
  {
    float length;
    if( getTotalNumberOfSubNodes() > 1 )
    {
      Vector2D area = getOverallArea();
      length = area.length();// + getTotalNumberOfSubNodes() / 10.0;
    }
    else
    {
      length = DNVEdge.DEFAULT_RESTING_DISTANCE;
    }
View Full Code Here

      acceleration = force;
      // acceleration.dotProduct( Math.min( 100.0 / mass, 1.0 ) );
      acceleration.dotProduct( timeStep[0] );
      if( acceleration.length() > MAX_FORCE )
        acceleration.normalize().dotProduct( MAX_FORCE );
      Vector2D tempVelocity[] = { new Vector2D( 0, 0 ), new Vector2D( 0, 0 ) };
      Vector2D tempPositionIncrement[] = { new Vector2D( 0, 0 ), new Vector2D( 0, 0 ) };
      Vector2D tempVector = new Vector2D();
      tempVelocity[0].set( velocity );
      tempVector.set( acceleration );
      tempVector.dotProduct( timeStep[0] );
      tempVelocity[0].add( tempVector );
      tempVector.set( tempVelocity[0] );
      tempVector.dotProduct( timeStep[0] );
      tempPositionIncrement[0].set( tempVector );
      tempPositionIncrement[0].dotProduct( timeStep[0] );

      tempVelocity[1].set( tempVelocity[0] );
      tempVector.set( acceleration );
      tempVector.dotProduct( timeStep[1] );
      tempVelocity[1].add( tempVector );
      tempVector.set( tempVelocity[1] );
      tempVector.dotProduct( timeStep[1] );
      tempPositionIncrement[1].set( tempVector );
      tempPositionIncrement[1].dotProduct( timeStep[1] );

      // tempVelocity[1].add( tempVelocity[0].dotProduct( timeStep[0] ) );
      tempPositionIncrement[1].add( tempPositionIncrement[0] );
View Full Code Here

    try
    {
      FileWriter fw = new FileWriter( file );
      fw.write( "Filename, Part, Number of Nodes, Number of Edges, Average Time in Milliseconds, Maximum Depth, Number of Iterations\n" );
      DNVGraph graph;
      Vector2D movement = new Vector2D();
      int maxDepth = Integer.MAX_VALUE;
      int level = 0;
      double globalMaxY;
      double globalMinY;
      double globalMaxX;
      double globalMinX;
      DNVNode movedNode;
      int graphSize;
      int tempIndex;
      String tempFileName;
      Timer[] selectionTimers = new Timer[fileNames.length];
      Timer[] movementTimers = new Timer[fileNames.length];
      for( int i = 0; i < fileNames.length; i++ )
      {
        graph = new DNVGraph( fileNames[i] );
        globalMaxY = GraphFunctions.getMaxYPosition( graph, level, false );
        globalMinY = GraphFunctions.getMinYPosition( graph, level, false );
        globalMaxX = GraphFunctions.getMaxXPosition( graph, level, false );
        globalMinX = GraphFunctions.getMinXPosition( graph, level, false );
        if( globalMinY == globalMaxY )
        {
          globalMinY -= 10;
          globalMaxY += 10;
        }
        if( globalMinX == globalMaxX )
        {
          globalMinX -= 10;
          globalMaxX += 10;
        }
        movement.setX( getRandomSign() * (float)( globalMaxX - globalMinX ) / 3.0f );
        movement.setY( getRandomSign() * (float)( globalMaxY - globalMinY ) / 3.0f );
        graphSize = graph.getGraphSize( level );
        System.out.print( "---------------------------------------------------------------------------------------\n" );
        System.out.print( "Results for " + fileNames[i] + "\n" );
        for( int k = 0; k < maxDepths.length; k++ )
        {
View Full Code Here

        }
        // check if the node already exists in the graph
        fromNode = (DNVNode)dnvGraph.getNodeById( fromId );
        if( fromNode == null )
        {
          fromNode = new DNVNode( new Vector2D( (float)Math.random(), (float)Math.random() ), dnvGraph );
          fromNode.setLevel( 0 );
          fromNode.setId( new Integer( fromId ) );
          fromNode.setLabel( "" + fromId );
          dnvGraph.addNode( 0, fromNode );
        }
        toNode = (DNVNode)dnvGraph.getNodeById( toId );
        if( toNode == null )
        {
          toNode = new DNVNode( new Vector2D( (float)Math.random(), (float)Math.random() ), dnvGraph );
          toNode.setLevel( 0 );
          toNode.setId( new Integer( toId ) );
          toNode.setLabel( "" + toId );
          dnvGraph.addNode( 0, toNode );
        }
View Full Code Here

TOP

Related Classes of net.wigis.graph.dnv.utilities.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.