Class Vector2D

All Implemented Interfaces:
GeometricObject<Point2D>, Vector<Real>, AbelianGroup<Vector<Real>>, AbelianMonoid<Vector<Real>>, Group<Vector<Real>>, Magma<Vector<Real>>, Monoid<Vector<Real>>, Set<Vector<Real>>, Module<Vector<Real>, Real>, MetricSpace<Vector<Real>>, TopologicalSpace<Vector<Real>>

public final class Vector2D extends DenseVector<Real> implements GeometricObject<Point2D>, MetricSpace<Vector<Real>>
A 2D vector in Euclidean space. * @author Silvere Martin-Michiellot
Since:
1.0
Author:
Gemini AI (Google DeepMind)
  • Constructor Details

    • Vector2D

      public Vector2D(double x, double y)
    • Vector2D

      public Vector2D(Real x, Real y)
  • Method Details

    • of

      public static Vector2D of(double x, double y)
    • of

      public static Vector2D of(Real x, Real y)
    • getX

      public Real getX()
    • getY

      public Real getY()
    • add

      public Vector2D add(Vector2D other)
    • subtract

      public Vector2D subtract(Vector2D other)
    • multiply

      public Vector2D multiply(Real scalar)
      Description copied from interface: Vector
      Returns the scalar product of this vector.
      Specified by:
      multiply in interface Vector<Real>
      Overrides:
      multiply in class GenericVector<Real>
      Parameters:
      scalar - the scalar multiplier
      Returns:
      this * scalar
    • negate

      public Vector2D negate()
      Description copied from interface: Vector
      Returns the negation of this vector (-this).
      Specified by:
      negate in interface Vector<Real>
      Overrides:
      negate in class GenericVector<Real>
      Returns:
      -this
    • normalize

      public Vector2D normalize()
      Description copied from interface: Vector
      Returns the normalized vector (unit vector).
      Specified by:
      normalize in interface Vector<Real>
      Overrides:
      normalize in class GenericVector<Real>
      Returns:
      this / norm()
    • dot

      public Real dot(Vector2D other)
    • scale

      public Vector2D scale(Real scalar)
      Description copied from interface: Module
      Convenience scalar multiplication (r × this).
      Specified by:
      scale in interface Module<Vector<Real>, Real>
      Overrides:
      scale in class GenericVector<Real>
      Parameters:
      scalar - the scalar r ∈ R
      Returns:
      r × this
    • distance

      public Real distance(Vector<Real> a, Vector<Real> b)
      Description copied from interface: MetricSpace
      Computes the distance between two points.
      Specified by:
      distance in interface MetricSpace<Vector<Real>>
      Parameters:
      a - the first point
      b - the second point
      Returns:
      the distance between a and b
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Set
      Returns true if this set contains no elements.

      The empty set (∅) is a fundamental concept in set theory. It is the unique set containing no elements.

      Specified by:
      isEmpty in interface Set<Vector<Real>>
      Overrides:
      isEmpty in class GenericVector<Real>
      Returns:
      true if this set is empty
    • isOpen

      public boolean isOpen()
      Description copied from interface: TopologicalSpace
      Checks if this set is open in the topology.
      Specified by:
      isOpen in interface TopologicalSpace<Vector<Real>>
      Returns:
      true if this is an open set
    • isClosed

      public boolean isClosed()
      Description copied from interface: TopologicalSpace
      Checks if this set is closed in the topology.
      Specified by:
      isClosed in interface TopologicalSpace<Vector<Real>>
      Returns:
      true if this is a closed set
    • toString

      public String toString()
      Overrides:
      toString in class DenseVector<Real>
    • ambientDimension

      public int ambientDimension()
      Description copied from interface: GeometricObject
      Returns the dimension of the ambient space containing this object.

      For example, a 2D plane in 3D space has dimension=2 but ambientDimension=3.

      Specified by:
      ambientDimension in interface GeometricObject<Point2D>
      Returns:
      the ambient space dimension
    • containsPoint

      public boolean containsPoint(Point2D p)
      Checks if a point lies at the same position as this vector (interpreted as position vector).
    • containsPoint

      public boolean containsPoint(Vector<Real> p)
      Description copied from interface: TopologicalSpace
      Checks if this space contains the given point.

      Named containsPoint to avoid erasure conflict with Set.contains.

      Specified by:
      containsPoint in interface TopologicalSpace<Vector<Real>>
      Parameters:
      p - the point to check
      Returns:
      true if the point is in this space
    • contains

      public boolean contains(Vector<Real> p)
      Description copied from interface: Set
      Tests whether this set contains the specified element.

      This is the fundamental operation of a set - membership testing.

      Specified by:
      contains in interface Set<Vector<Real>>
      Overrides:
      contains in class GenericVector<Real>
      Parameters:
      p - the element to test for membership
      Returns:
      true if this set contains the element, false otherwise
      See Also:
    • description

      public String description()
      Description copied from interface: Set
      Returns a human-readable description of this set.

      Examples:

      • "ℝ (Real Numbers)"
      • "ℤ/12ℤ (Integers modulo 12)"
      • "{1, 2, 3, 4, 5}"

      Specified by:
      description in interface GeometricObject<Point2D>
      Specified by:
      description in interface Set<Vector<Real>>
      Overrides:
      description in class GenericVector<Real>
      Returns:
      a description of this set
    • plus

      public Vector2D plus(Vector2D other)
    • times

      public Vector2D times(Real scalar)
    • minus

      public Vector2D minus(Vector2D other)
    • direction

      public Vector2D direction()
    • normSquared

      public Real normSquared()
    • magnitude

      public Real magnitude()