Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Point2D

[14:7] extends: FxObj

Wraps JavaFX Point2D, an immutable 2D coordinate or vector with double precision X and Y components. Point2D is returned by the Node coordinate transform helpers (screenToLocal, localToScene, and friends) and is used throughout the 2D layout and geometry API for positions and vector math.

Methods

  • Point2D (X = null, Y = null)

    Creates a new Point2D from X and Y, or wraps an existing Point2D AJO.

    • @p X is a double with the X coordinate, or a Point2D AJO to wrap.
    • @p Y is a double with the Y coordinate.
  • getX ()

    Returns the X component of this point.

    • @r A double with the X value.
  • getY ()

    Returns the Y component of this point.

    • @r A double with the Y value.
  • magnitude ()

    Returns the magnitude (length) of this point treated as a vector.

    • @r A double with the magnitude.
  • distance (object Other)

    Returns the distance from this point to Other.

    • @p Other is a Point2D with the target point.
    • @r A double with the distance.
  • normalize ()

    Returns a new normalized (unit length) Point2D in the same direction.

    • @r A new Point2D with unit length.
  • add (object Other)

    Returns a new Point2D that is the sum of this point and Other.

    • @p Other is a Point2D added to this point.
    • @r A new Point2D with the sum.
  • subtract (object Other)

    Returns a new Point2D that is this point minus Other.

    • @p Other is a Point2D subtracted from this point.
    • @r A new Point2D with the difference.
  • midpoint (object Other)

    Returns a new Point2D at the midpoint between this point and Other.

    • @p Other is a Point2D at the other end of the segment.
    • @r A new Point2D at the midpoint.
  • dotProduct (object Other)

    Returns the dot product of this point and Other.

    • @p Other is a Point2D for the operand.
    • @r A double with the dot product.
  • angle (object Other)

    Returns the angle in degrees between this vector and Other.

    • @p Other is a Point2D.
    • @r A double with the angle in degrees.
  • interpolate (object Other, double Frac)

    Linearly interpolates between this point and Other by Frac. Frac 0.0 returns this point and 1.0 returns Other.

    • @p Other is a Point2D at the end of the interpolation.
    • @p Frac is a double interpolation factor in the range 0.0 to 1.0.
    • @r A new Point2D at the interpolated position.