Documentation of 'math.geom2d.line.Line2D' Java class
Line2D
math.geom2d.line

Class Line2D

    • Field Detail

      • p1

        public Point2D p1
        The origin point.
      • p2

        public Point2D p2
        The destination point.
    • Constructor Detail

      • Line2D

        public Line2D(Point2D point1,
                      Point2D point2)
        Define a new Line2D with two extremities.
      • Line2D

        public Line2D(double x1,
                      double y1,
                      double x2,
                      double y2)
        Define a new Line2D with two extremities.
      • Line2D

        public Line2D(Line2D line)
        Copy constructor.
    • Method Detail

      • intersects

        public static boolean intersects(Line2D line1,
                                         Line2D line2)
        Checks if two line intersect. Uses the Point2D.ccw method, which is based on Sedgewick algorithm.
        Parameters:
        line1 - a Line2D object
        line2 - a Line2D object
        Returns:
        true if the 2 lines intersect
      • create

        @Deprecated
        public static Line2D create(Point2D p1,
                                                Point2D p2)
        Deprecated. since 0.11.1
        Static factory for creating a new Line2D, starting from p1 and finishing at p2.
      • getPoint1

        public Point2D getPoint1()
        Return the first point of the edge. It corresponds to getPoint(0).
        Returns:
        the first point.
      • getPoint2

        public Point2D getPoint2()
        Return the last point of the edge. It corresponds to getPoint(1).
        Returns:
        the last point.
      • getX1

        public double getX1()
      • getY1

        public double getY1()
      • getX2

        public double getX2()
      • getY2

        public double getY2()
      • getOtherPoint

        public Point2D getOtherPoint(Point2D point)
        Return the opposite vertex of the edge.
        Parameters:
        point - : one of the vertices of the edge
        Returns:
        the other vertex
      • setPoint1

        public void setPoint1(Point2D point)
      • setPoint2

        public void setPoint2(Point2D point)
      • isParallel

        public boolean isParallel(LinearShape2D line)
        Test if the this object is parallel to the given one. This method is overloaded to update parameters before computation.
      • buffer

        public CirculinearDomain2D buffer(double dist)
        Description copied from interface: CirculinearShape2D
        Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d.
        Specified by:
        buffer in interface CirculinearShape2D
        Parameters:
        dist - the maximal distance between a point of the buffer and the shape
        Returns:
        the buffer of the shape
      • parallel

        public Line2D parallel(double d)
        Description copied from interface: CirculinearCurve2D
        Creates a new curve, formed by the points with parameterization: p(t) = c(t) + d*n(t)/|n(t)|, with p(t) being a point of the original curve, n(t) the normal of the curve, and |n| being the norm of n.
        In the case of a continuous curve formed by several smooth circulinear elements, the parallels of contiguous elements are joined by a circle arc.
        Specified by:
        parallel in interface CirculinearContinuousCurve2D
        Specified by:
        parallel in interface CirculinearCurve2D
        Specified by:
        parallel in interface CirculinearElement2D
        Parameters:
        d - the distance between the original curve and he parallel curve.
        Returns:
        the parallel curve
      • length

        public double length()
        Specified by:
        length in interface CirculinearCurve2D
        Returns:
        the length of the curve
      • length

        public double length(double pos)
        Specified by:
        length in interface CirculinearCurve2D
        Returns:
        the length from the beginning to the position given by pos
      • position

        public double position(double length)
        Specified by:
        position in interface CirculinearCurve2D
        Returns:
        the position located at a given geodesic distance from the origin
      • parametric

        public double[][] parametric()
      • cartesianEquation

        public double[] cartesianEquation()
      • polarCoefficients

        public double[] polarCoefficients()
      • polarCoefficientsSigned

        public double[] polarCoefficientsSigned()
      • horizontalAngle

        public double horizontalAngle()
        Description copied from interface: LinearShape2D
        Returns the angle with axis (O,i), counted counter-clockwise. Result is given between 0 and 2*pi.
        Specified by:
        horizontalAngle in interface LinearShape2D
      • intersection

        public Point2D intersection(LinearShape2D line)
        Description copied from interface: LinearShape2D
        Returns the unique intersection with a linear shape. If the intersection doesn't exist (parallel lines), returns null.
        Specified by:
        intersection in interface LinearShape2D
      • origin

        public Point2D origin()
        Description copied from interface: LinearShape2D
        Returns a point in the linear shape.
        Specified by:
        origin in interface LinearShape2D
        Returns:
        a point in the linear shape.
      • supportingLine

        public StraightLine2D supportingLine()
        Description copied from interface: LinearShape2D
        Returns the straight line that contains this linear shape. The direction is the same, and if possible the direction vector should be the same.
        Specified by:
        supportingLine in interface LinearShape2D
        Returns:
        the straight line that contains this linear shape
      • direction

        public Vector2D direction()
        Description copied from interface: LinearShape2D
        Return one direction vector of the linear shape.
        Specified by:
        direction in interface LinearShape2D
        Returns:
        a direction vector
      • signedDistance

        public double signedDistance(Point2D p)
        Description copied from interface: OrientedCurve2D
        Returns the signed distance of the curve to the given point. The distance is positive if the point lies outside the shape, and negative if the point lies inside the shape. In both cases, absolute value of distance is equals to the distance to the border of the shape.
        Specified by:
        signedDistance in interface OrientedCurve2D
        Parameters:
        p - a point of the plane
        Returns:
        the signed distance to the curve
      • signedDistance

        public double signedDistance(double x,
                                     double y)
        Description copied from interface: OrientedCurve2D
        The same as distanceSigned(Point2D), but by passing 2 double as arguments.
        Specified by:
        signedDistance in interface OrientedCurve2D
        Parameters:
        x - x-coord of a point
        y - y-coord of a point
        Returns:
        the signed distance of the point (x,y) to the curve
      • distance

        public double distance(Point2D p)
        Returns the distance of the point p to this edge.
        Specified by:
        distance in interface Shape2D
      • distance

        public double distance(double x,
                               double y)
        Returns the distance of the point (x, y) to this edge.
        Specified by:
        distance in interface Shape2D
      • parallel

        public StraightLine2D parallel(Point2D point)
        Creates a straight line parallel to this object, and passing through the given point.
        Parameters:
        point - the point to go through
        Returns:
        the parallel through the point
      • perpendicular

        public StraightLine2D perpendicular(Point2D point)
        Creates a straight line perpendicular to this object, and passing through the given point.
        Parameters:
        point - the point to go through
        Returns:
        the perpendicular through point
      • boundingBox

        public Box2D boundingBox()
        Returns the bounding box of the Line2D.
        Specified by:
        boundingBox in interface Shape2D
        Returns:
        the bounding box of the shape.
      • curvature

        public double curvature(double t)
        Returns 0 as every linear shape.
        Specified by:
        curvature in interface ContinuousCurve2D
        Parameters:
        t - the position on the curve
        Returns:
        the curvature of the curve for position t
      • windingAngle

        public double windingAngle(Point2D point)
        Description copied from interface: OrientedCurve2D
        Return the angle portion that the curve turn around the given point. Result is a signed angle.
        Specified by:
        windingAngle in interface OrientedCurve2D
        Parameters:
        point - a point of the plane
        Returns:
        a signed angle
      • isInside

        public boolean isInside(Point2D point)
        Description copied from interface: OrientedCurve2D
        Returns true if the point is 'inside' the domain bounded by the curve.
        Specified by:
        isInside in interface OrientedCurve2D
        Parameters:
        point - a point in the plane
        Returns:
        true if the point is on the left side of the curve.
      • t0

        public double t0()
        Returns 0.
        Specified by:
        t0 in interface Curve2D
      • getT0

        @Deprecated
        public double getT0()
        Deprecated. replaced by t0() (since 0.11.1).
        Specified by:
        getT0 in interface Curve2D
      • t1

        public double t1()
        Returns 1.
        Specified by:
        t1 in interface Curve2D
      • getT1

        @Deprecated
        public double getT1()
        Deprecated. replaced by t1() (since 0.11.1).
        Specified by:
        getT1 in interface Curve2D
      • point

        public Point2D point(double t)
        Description copied from interface: Curve2D
        Returns the point located at the given position on the curve. If the parameter lies outside the definition range, the parameter corresponding to the closest bound is used instead. This method can be used to draw an approximated outline of a curve, by selecting multiple values for t and drawing lines between them.
        Specified by:
        point in interface Curve2D
      • position

        public double position(Point2D point)
        Returns the position of the point on the line. If point belongs to the line, this position is defined by the ratio:

        t = (xp - x0)/dx <\code>, or equivalently :

        t = (yp - y0)/dy <\code>.

        If point does not belong to edge, return Double.NaN. The current implementation uses the direction with the biggest derivative, in order to avoid divisions by zero.

        Specified by:
        position in interface Curve2D
        Parameters:
        point - a point belonging to the curve
        Returns:
        the position of the point on the curve
        See Also:
        Curve2D.point(double)
      • project

        public double project(Point2D point)
        Description copied from interface: Curve2D
        Returns the position of the closest orthogonal projection of the point on the curve, or of the closest singular point. This function should always returns a valid value.
        Specified by:
        project in interface Curve2D
        Parameters:
        point - a point to project
        Returns:
        the position of the closest orthogonal projection
      • intersections

        public java.util.Collection<Point2D> intersections(LinearShape2D line)
        Description copied from interface: Curve2D
        Returns the intersection points of the curve with the specified line. The length of the result array is the number of intersection points.
        Specified by:
        intersections in interface Curve2D
      • contains

        public boolean contains(double x,
                                double y)
        Returns true if the point (x, y) lies on the line, with precision given by Shape2D.ACCURACY.
        Specified by:
        contains in interface Shape2D
      • contains

        public boolean contains(Point2D p)
        Returns true if the point p lies on the line, with precision given by Shape2D.ACCURACY.
        Specified by:
        contains in interface Shape2D
      • isBounded

        public boolean isBounded()
        Returns true
        Specified by:
        isBounded in interface Shape2D
      • isEmpty

        public boolean isEmpty()
        Returns false
        Specified by:
        isEmpty in interface Shape2D
        Returns:
        true if the shape does not contain any point.
      • getGeneralPath

        public java.awt.geom.GeneralPath getGeneralPath()
      • appendPath

        public java.awt.geom.GeneralPath appendPath(java.awt.geom.GeneralPath path)
        Description copied from interface: ContinuousCurve2D
        Append the path of the curve to the given path.
        Specified by:
        appendPath in interface ContinuousCurve2D
        Parameters:
        path - a path to modify
        Returns:
        the modified path
      • almostEquals

        public boolean almostEquals(GeometricObject2D obj,
                                    double eps)
        Description copied from interface: GeometricObject2D
        Checks if the two objects are similar up to a given threshold value. This method can be used to compare the results of geometric computations, that introduce errors due to numerical computations.
        Specified by:
        almostEquals in interface GeometricObject2D
        Parameters:
        obj - the object to compare
        eps - a threshold value, for example the minimal coordinate difference
        Returns:
        true if both object have the same value up to the threshold
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals(java.lang.Object obj)
        Two Line2D are equals if the share the two same points, in the same order.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the edge to compare to.
        Returns:
        true if extremities of both edges are the same.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.