Package net.wigis.graph.dnv.utilities

Examples of net.wigis.graph.dnv.utilities.Vector2D.subtract()


    Vector2D zeroPixels = ImageRenderer.transformScreenToWorld( 0, 0, minX, maxX, minY, maxY, globalMinX, globalMaxX, globalMinY, globalMaxY, width, height );

    Vector2D fivePixels = ImageRenderer.transformScreenToWorld( 5, 5, minX, maxX, minY, maxY, globalMinX, globalMaxX, globalMinY, globalMaxY, width, height );

    fivePixels.subtract( zeroPixels );

    Vector2D movement = new Vector2D( 0, 0 );
    if( selectedNode == null && sameNode )
    {
      selectedNode = pb.getSelectedNode();
View Full Code Here


        for( DNVNode u : potentialNodes )
        {
          if( u != v )
          {
            difference.set( v.getPosition() );
            difference.subtract( u.getPosition() );
            length = difference.length();
            if( length == 0 )
            {
              difference.set( (float)Math.random() - 0.5f, (float)Math.random() - 0.5f );
              length = difference.length();
View Full Code Here

      // attractive forces
      for( DNVEdge e : graph.getEdges( level ) )
      {
        difference.set( e.getFrom().getPosition() );
        difference.subtract( e.getTo().getPosition() );
        length = difference.length();
        difference.normalize();
        difference.dotProduct( attract( length, k ) );
        e.getFrom().getForce().subtract( difference );
        e.getTo().getForce().add( difference );
View Full Code Here

      for( DNVNode u : potentialNodes )
      {
        if( u != v )
        {
          difference.set( v.getPosition() );
          difference.subtract( u.getPosition() );
          length = difference.length();
          // If two nodes are in exact same position
          // then we need to do something to move them apart.
          // Give them a small repelling force in random direction.
          if( length == 0 )
View Full Code Here

    // attractive forces
    for( DNVEdge e : edges )
    {
      difference.set( e.getFrom().getPosition() );
      difference.subtract( e.getTo().getPosition() );
      length = difference.length();
      if( useRestingDistance )
      {
        length = length - e.getRestingDistance();
        length = length * e.getK();
 
View Full Code Here

      for( DNVNode u : potentialNodes )
      {
        if( u != v )
        {
          difference.set( v.getPosition() );
          difference.subtract( u.getPosition() );
          length = difference.length();
          // If two nodes are in exact same position
          // then we need to do something to move them apart.
          // Give them a small repelling force in random direction.
          if( length == 0 )
View Full Code Here

    // attractive forces
    for( DNVEdge e : edges )
    {
      difference.set( e.getFrom().getPosition() );
      difference.subtract( e.getTo().getPosition() );
      length = difference.length();
      difference.normalize();
      difference.dotProduct( attract( length, k ) );
      e.getFrom().getForce().subtract( difference );
      e.getTo().getForce().add( difference );
View Full Code Here

  private static void forceToCircle( List<DNVNode> nodes, Vector2D center, int radius )
  {
    for( DNVNode v : nodes )
    {
      Vector2D newPos = new Vector2D( v.getPosition() );
      newPos.subtract( center );
      newPos.normalize();
      newPos.dotProduct( radius );
      newPos.add( center );
      v.setPosition( newPos );
    }
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.