Class Node2D

Object
Point2D
Node2D
All Implemented Interfaces:
Node, Point

public class Node2D extends Point2D implements Node
Class representing a (network) node in 2D space with position and radius.
Author:
Christoph Hauert
  • Field Details

    • r

      public double r
      The radius r of the 2D node.
  • Constructor Details

    • Node2D

      public Node2D()
      Create a new 2D node at (0,0) with radius r=0.
    • Node2D

      public Node2D(Node2D n)
      Create a copy of the 2D node n.
      Parameters:
      n - the node to copy
    • Node2D

      public Node2D(double x, double y, double r)
      Create a new 2D node at (x,y) with radius r.
      Parameters:
      x - the x-coordinate
      y - the y-coordinate
      r - the radius
  • Method Details

    • set

      public Node2D set(double x, double y, double r)
      Set the x- and y-coordinates and the radius r of 2D node.
      Parameters:
      x - the x-coordinate
      y - the y-coordinate
      r - the radius
      Returns:
      this node
    • set

      public Node2D set(Node2D n)
      Set the coordinates and radious to those of node n.
      Parameters:
      n - the node to copy
      Returns:
      this node
    • getR

      public double getR()
      Get the radius r of this 2D node.
      Returns:
      the radius
    • setR

      public Node2D setR(double r)
      Set the radius r of this 2D node.
      Parameters:
      r - the new radius
      Returns:
      this node
    • scaleR

      public Node2D scaleR(double scale)
      Description copied from interface: Node
      Scales the radius of this node by scale.
      Specified by:
      scaleR in interface Node
      Parameters:
      scale - the scaling factor
      Returns:
      this node
    • distance2

      public double distance2(Node2D m)
      Calculate the distance squared between this 2D node n and node m. The distance is between the nodes, i.e. takes their respective radii into account |n-m|<sup>2</sup>.
      Parameters:
      m - the node to calculate distance to
      Returns:
      the distance to node m
    • distance

      public double distance(Node2D m)
      Calculate the distance between this 2D node n and node m. The distance is between the nodes, i.e. takes their respective radii into account |n-m|<sup>2</sup>.

      For computational efficiency the fairly expensive square-roots calculations should be avoided whenever possible.

      Parameters:
      m - the node to calculate distance to
      Returns:
      the distance to node m
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Point2D