Package wprover

Class Constraint


  • public class Constraint
    extends java.lang.Object
    The Constraint class represents a geometric constraint in a geometric construction. It contains methods to generate and manipulate constraints, as well as to calculate polynomial representations of the constraints.
    • Constructor Summary

      Constructors 
      Constructor Description
      Constraint​(int id)
      Constructs a Constraint with the specified ID.
      Constraint​(int type, java.lang.Object obj)
      Constructs a Constraint with a single element.
      Constraint​(int type, java.lang.Object obj1, int prop)
      Constructs a Constraint with a single element and a proportion, and generates the polynomial if required.
      Constraint​(int type, java.lang.Object obj1, java.lang.Object obj2)
      Constructs a Constraint with two elements and generates the polynomial if required.
      Constraint​(int type, java.lang.Object obj1, java.lang.Object obj2, boolean gpoly)
      Constructs a Constraint with two elements and optionally generates the polynomial.
      Constraint​(int type, java.lang.Object obj1, java.lang.Object obj2, java.lang.Object obj3)
      Constructs a Constraint with three elements and generates the polynomial if required.
      Constraint​(int type, java.lang.Object obj1, java.lang.Object obj2, java.lang.Object obj3, int prop)
      Constructs a Constraint with three elements and a proportion, and generates the polynomial if required.
      Constraint​(int type, java.lang.Object obj1, java.lang.Object obj2, java.lang.Object obj3, java.lang.Object obj4)
      Constructs a Constraint with four elements and generates the polynomial if required.
      Constraint​(int type, java.lang.Object obj1, java.lang.Object obj2, java.lang.Object obj3, java.lang.Object obj4, int prop)
      Constructs a Constraint with four elements and a proportion, and generates the polynomial if required.
      Constraint​(int type, java.lang.Object obj1, java.lang.Object obj2, java.lang.Object obj3, java.lang.Object obj4, java.lang.Object obj5)
      Constructs a Constraint with five elements and generates the polynomial if required.
      Constraint​(int type, java.lang.Object obj1, java.lang.Object obj2, java.lang.Object obj3, java.lang.Object obj4, java.lang.Object obj5, java.lang.Object obj6)
      Constructs a Constraint with six elements and generates the polynomial if required.
      Constraint​(int type, java.util.Vector olist)
      Constructs a Constraint with a list of elements and generates the polynomial.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add_des​(int t, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5)
      Adds a constraint description with five objects to the list of constraints.
      void add_des​(int t, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5, java.lang.Object p6)
      Adds a constraint description with six objects to the list of constraints.
      void add_des​(int t, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5, java.lang.Object p6, java.lang.Object p7)
      Adds a constraint description with seven objects to the list of constraints.
      void add_des​(int t, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5, java.lang.Object p6, java.lang.Object p7, java.lang.Object p8)
      Adds a constraint description with eight objects to the list of constraints.
      void add_des​(int t, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5, java.lang.Object p6, java.lang.Object p7, java.lang.Object p8, java.lang.Object p9, java.lang.Object p10)
      Adds a constraint description with ten objects to the list of constraints.
      void add_des​(int t, java.util.Vector v)
      Adds a constraint description with a vector of points to the list of constraints.
      void add_des​(int t, CPoint p1, CPoint p2, CPoint p3)
      Adds a constraint description with three points to the list of constraints.
      void add_des​(int t, CPoint p1, CPoint p2, CPoint p3, java.lang.Object obj)
      Adds a constraint description with three points and an additional object to the list of constraints.
      void add_des​(int t, CPoint p1, CPoint p2, CPoint p3, CPoint p4)
      Adds a constraint description with four points to the list of constraints.
      void add_desx1​(int t, CPoint p1, CPoint p2, CPoint p3, CPoint p4)
      Adds a constraint description with four points to the list of constraints, ensuring the points are ordered by their x-index.
      void addelement​(java.lang.Object obj)
      Adds an element to the element list if it is not null.
      void addElement​(java.lang.Object obj)
      Adds an element to the element list.
      void addPoly​(TPoly tp)
      Adds a polynomial to the polynomial list.
      boolean addZeron​(TMono m1)
      Adds a zero coefficient to the TMono object if its length is 1.
      void calculate​(Param[] para)
      Calculates the polynomial representation using the given parameters.
      boolean check_agbisector​(double x, double y)
      Checks if the angle bisector constraint is satisfied for the given coordinates.
      boolean check_constraint​(double x, double y)
      Checks if the constraint is satisfied for the given coordinates.
      boolean check_incenter​(double x, double y)
      Checks if the incenter constraint is satisfied for the given coordinates.
      void clear_all_cons()
      Clears all constraints by setting the constraint descriptors to null.
      boolean compareLN​(CLine ln1, CLine ln2)
      Compares two lines based on the ID of their first points.
      double dr_pr​(double x1, double y1, double x2, double y2, double x, double y)
      Calculates the determinant of the given points.
      TMono eqdistance​(CPoint p1, CPoint p2, CPoint p3, CPoint p4)
      Creates a TMono object representing the equality of distances between two pairs of points.
      static double get_sp_ag_value​(int v)
      Returns the special angle value for the given angle in degrees.
      java.util.Vector getAllElements()
      Retrieves all elements in the element list.
      int GetConstraintType()
      Gets the type of the constraint.
      java.lang.Object getelement​(int i)
      Retrieves an element from the element list at the specified index.
      static TPoly getPolyListAndSetNull()
      Retrieves the polynomial list and sets it to null.
      boolean less​(CPoint a, CPoint b)
      Compares two points based on their x-index.
      void Load​(java.io.DataInputStream in, DrawProcess dp)
      Loads the constraint data from a DataInputStream.
      TPoly NewTPoly​(TMono m1, TMono m2)
      Creates a new TPoly object from two TMono objects.
      TMono parseTMonoString​(java.lang.String name, java.lang.String func, int x)
      Parses a TMono object from a string representation.
      void Save​(java.io.DataOutputStream out)
      Saves the constraint data to a DataOutputStream.
      void setPolyGenerate​(boolean r)
      Sets whether the polynomial should be generated.
      java.lang.String toString()
      Returns the string representation of the constraint.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Constraint

        public Constraint​(int id)
        Constructs a Constraint with the specified ID.
        Parameters:
        id - the ID of the constraint
      • Constraint

        public Constraint​(int type,
                          java.lang.Object obj1,
                          java.lang.Object obj2,
                          boolean gpoly)
        Constructs a Constraint with two elements and optionally generates the polynomial.
        Parameters:
        type - the type of the constraint
        obj1 - the first element
        obj2 - the second element
        gpoly - true if the polynomial should be generated, false otherwise
      • Constraint

        public Constraint​(int type,
                          java.util.Vector olist)
        Constructs a Constraint with a list of elements and generates the polynomial.
        Parameters:
        type - the type of the constraint
        olist - a vector containing the elements
      • Constraint

        public Constraint​(int type,
                          java.lang.Object obj)
        Constructs a Constraint with a single element.
        Parameters:
        type - the type of the constraint
        obj - the element
      • Constraint

        public Constraint​(int type,
                          java.lang.Object obj1,
                          java.lang.Object obj2)
        Constructs a Constraint with two elements and generates the polynomial if required.
        Parameters:
        type - the type of the constraint
        obj1 - the first element
        obj2 - the second element
      • Constraint

        public Constraint​(int type,
                          java.lang.Object obj1,
                          java.lang.Object obj2,
                          java.lang.Object obj3,
                          int prop)
        Constructs a Constraint with three elements and a proportion, and generates the polynomial if required.
        Parameters:
        type - the type of the constraint
        obj1 - the first element
        obj2 - the second element
        obj3 - the third element
        prop - the proportion
      • Constraint

        public Constraint​(int type,
                          java.lang.Object obj1,
                          int prop)
        Constructs a Constraint with a single element and a proportion, and generates the polynomial if required.
        Parameters:
        type - the type of the constraint
        obj1 - the element
        prop - the proportion
      • Constraint

        public Constraint​(int type,
                          java.lang.Object obj1,
                          java.lang.Object obj2,
                          java.lang.Object obj3,
                          java.lang.Object obj4,
                          int prop)
        Constructs a Constraint with four elements and a proportion, and generates the polynomial if required.
        Parameters:
        type - the type of the constraint
        obj1 - the first element
        obj2 - the second element
        obj3 - the third element
        obj4 - the fourth element
        prop - the proportion
      • Constraint

        public Constraint​(int type,
                          java.lang.Object obj1,
                          java.lang.Object obj2,
                          java.lang.Object obj3,
                          java.lang.Object obj4,
                          java.lang.Object obj5)
        Constructs a Constraint with five elements and generates the polynomial if required.
        Parameters:
        type - the type of the constraint
        obj1 - the first element
        obj2 - the second element
        obj3 - the third element
        obj4 - the fourth element
        obj5 - the fifth element
      • Constraint

        public Constraint​(int type,
                          java.lang.Object obj1,
                          java.lang.Object obj2,
                          java.lang.Object obj3)
        Constructs a Constraint with three elements and generates the polynomial if required.
        Parameters:
        type - the type of the constraint
        obj1 - the first element
        obj2 - the second element
        obj3 - the third element
      • Constraint

        public Constraint​(int type,
                          java.lang.Object obj1,
                          java.lang.Object obj2,
                          java.lang.Object obj3,
                          java.lang.Object obj4)
        Constructs a Constraint with four elements and generates the polynomial if required.
        Parameters:
        type - the type of the constraint
        obj1 - the first element
        obj2 - the second element
        obj3 - the third element
        obj4 - the fourth element
      • Constraint

        public Constraint​(int type,
                          java.lang.Object obj1,
                          java.lang.Object obj2,
                          java.lang.Object obj3,
                          java.lang.Object obj4,
                          java.lang.Object obj5,
                          java.lang.Object obj6)
        Constructs a Constraint with six elements and generates the polynomial if required.
        Parameters:
        type - the type of the constraint
        obj1 - the first element
        obj2 - the second element
        obj3 - the third element
        obj4 - the fourth element
        obj5 - the fifth element
        obj6 - the sixth element
    • Method Detail

      • getPolyListAndSetNull

        public static TPoly getPolyListAndSetNull()
        Retrieves the polynomial list and sets it to null.
        Returns:
        the current polynomial list
      • GetConstraintType

        public int GetConstraintType()
        Gets the type of the constraint.
        Returns:
        the type of the constraint
      • getelement

        public java.lang.Object getelement​(int i)
        Retrieves an element from the element list at the specified index.
        Parameters:
        i - the index of the element to retrieve
        Returns:
        the element at the specified index, or null if the index is out of bounds
      • getAllElements

        public java.util.Vector getAllElements()
        Retrieves all elements in the element list.
        Returns:
        a vector containing all elements in the element list
      • calculate

        public void calculate​(Param[] para)
        Calculates the polynomial representation using the given parameters.
        Parameters:
        para - an array of parameters to use for the calculation
      • addelement

        public void addelement​(java.lang.Object obj)
        Adds an element to the element list if it is not null.
        Parameters:
        obj - the element to be added
      • setPolyGenerate

        public void setPolyGenerate​(boolean r)
        Sets whether the polynomial should be generated.
        Parameters:
        r - true if the polynomial should be generated, false otherwise
      • addElement

        public void addElement​(java.lang.Object obj)
        Adds an element to the element list.
        Parameters:
        obj - the element to be added
      • toString

        public java.lang.String toString()
        Returns the string representation of the constraint.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the string representation of the constraint
      • clear_all_cons

        public void clear_all_cons()
        Clears all constraints by setting the constraint descriptors to null.
      • addPoly

        public void addPoly​(TPoly tp)
        Adds a polynomial to the polynomial list.
        Parameters:
        tp - the polynomial to be added
      • NewTPoly

        public TPoly NewTPoly​(TMono m1,
                              TMono m2)
        Creates a new TPoly object from two TMono objects.
        Parameters:
        m1 - the first TMono object
        m2 - the second TMono object
        Returns:
        the created TPoly object
      • Save

        public void Save​(java.io.DataOutputStream out)
                  throws java.io.IOException
        Saves the constraint data to a DataOutputStream.
        Parameters:
        out - the DataOutputStream to write to
        Throws:
        java.io.IOException - if an I/O error occurs
      • add_des

        public void add_des​(int t,
                            CPoint p1,
                            CPoint p2,
                            CPoint p3,
                            java.lang.Object obj)
        Adds a constraint description with three points and an additional object to the list of constraints.
        Parameters:
        t - the type of the constraint
        p1 - the first point
        p2 - the second point
        p3 - the third point
        obj - the additional object
      • add_des

        public void add_des​(int t,
                            CPoint p1,
                            CPoint p2,
                            CPoint p3)
        Adds a constraint description with three points to the list of constraints.
        Parameters:
        t - the type of the constraint
        p1 - the first point
        p2 - the second point
        p3 - the third point
      • add_des

        public void add_des​(int t,
                            java.util.Vector v)
        Adds a constraint description with a vector of points to the list of constraints.
        Parameters:
        t - the type of the constraint
        v - the vector of points
      • less

        public boolean less​(CPoint a,
                            CPoint b)
        Compares two points based on their x-index.
        Parameters:
        a - the first point
        b - the second point
        Returns:
        true if the x-index of the first point is less than the x-index of the second point, false otherwise
      • add_desx1

        public void add_desx1​(int t,
                              CPoint p1,
                              CPoint p2,
                              CPoint p3,
                              CPoint p4)
        Adds a constraint description with four points to the list of constraints, ensuring the points are ordered by their x-index.
        Parameters:
        t - the type of the constraint
        p1 - the first point
        p2 - the second point
        p3 - the third point
        p4 - the fourth point
      • add_des

        public void add_des​(int t,
                            CPoint p1,
                            CPoint p2,
                            CPoint p3,
                            CPoint p4)
        Adds a constraint description with four points to the list of constraints.
        Parameters:
        t - the type of the constraint
        p1 - the first point
        p2 - the second point
        p3 - the third point
        p4 - the fourth point
      • add_des

        public void add_des​(int t,
                            java.lang.Object p1,
                            java.lang.Object p2,
                            java.lang.Object p3,
                            java.lang.Object p4,
                            java.lang.Object p5)
        Adds a constraint description with five objects to the list of constraints.
        Parameters:
        t - the type of the constraint
        p1 - the first object
        p2 - the second object
        p3 - the third object
        p4 - the fourth object
        p5 - the fifth object
      • add_des

        public void add_des​(int t,
                            java.lang.Object p1,
                            java.lang.Object p2,
                            java.lang.Object p3,
                            java.lang.Object p4,
                            java.lang.Object p5,
                            java.lang.Object p6)
        Adds a constraint description with six objects to the list of constraints.
        Parameters:
        t - the type of the constraint
        p1 - the first object
        p2 - the second object
        p3 - the third object
        p4 - the fourth object
        p5 - the fifth object
        p6 - the sixth object
      • add_des

        public void add_des​(int t,
                            java.lang.Object p1,
                            java.lang.Object p2,
                            java.lang.Object p3,
                            java.lang.Object p4,
                            java.lang.Object p5,
                            java.lang.Object p6,
                            java.lang.Object p7,
                            java.lang.Object p8)
        Adds a constraint description with eight objects to the list of constraints.
        Parameters:
        t - the type of the constraint
        p1 - the first object
        p2 - the second object
        p3 - the third object
        p4 - the fourth object
        p5 - the fifth object
        p6 - the sixth object
        p7 - the seventh object
        p8 - the eighth object
      • add_des

        public void add_des​(int t,
                            java.lang.Object p1,
                            java.lang.Object p2,
                            java.lang.Object p3,
                            java.lang.Object p4,
                            java.lang.Object p5,
                            java.lang.Object p6,
                            java.lang.Object p7,
                            java.lang.Object p8,
                            java.lang.Object p9,
                            java.lang.Object p10)
        Adds a constraint description with ten objects to the list of constraints.
        Parameters:
        t - the type of the constraint
        p1 - the first object
        p2 - the second object
        p3 - the third object
        p4 - the fourth object
        p5 - the fifth object
        p6 - the sixth object
        p7 - the seventh object
        p8 - the eighth object
        p9 - the ninth object
        p10 - the tenth object
      • add_des

        public void add_des​(int t,
                            java.lang.Object p1,
                            java.lang.Object p2,
                            java.lang.Object p3,
                            java.lang.Object p4,
                            java.lang.Object p5,
                            java.lang.Object p6,
                            java.lang.Object p7)
        Adds a constraint description with seven objects to the list of constraints.
        Parameters:
        t - the type of the constraint
        p1 - the first object
        p2 - the second object
        p3 - the third object
        p4 - the fourth object
        p5 - the fifth object
        p6 - the sixth object
        p7 - the seventh object
      • Load

        public void Load​(java.io.DataInputStream in,
                         DrawProcess dp)
                  throws java.io.IOException
        Loads the constraint data from a DataInputStream.
        Parameters:
        in - the DataInputStream to read from
        dp - the DrawProcess instance to use for retrieving elements
        Throws:
        java.io.IOException - if an I/O error occurs
      • get_sp_ag_value

        public static double get_sp_ag_value​(int v)
        Returns the special angle value for the given angle in degrees.
        Parameters:
        v - the angle in degrees
        Returns:
        the special angle value
      • check_constraint

        public boolean check_constraint​(double x,
                                        double y)
        Checks if the constraint is satisfied for the given coordinates.
        Parameters:
        x - the x-coordinate
        y - the y-coordinate
        Returns:
        true if the constraint is satisfied, false otherwise
      • check_incenter

        public boolean check_incenter​(double x,
                                      double y)
        Checks if the incenter constraint is satisfied for the given coordinates.
        Parameters:
        x - the x-coordinate
        y - the y-coordinate
        Returns:
        true if the incenter constraint is satisfied, false otherwise
      • check_agbisector

        public boolean check_agbisector​(double x,
                                        double y)
        Checks if the angle bisector constraint is satisfied for the given coordinates.
        Parameters:
        x - the x-coordinate
        y - the y-coordinate
        Returns:
        true if the angle bisector constraint is satisfied, false otherwise
      • dr_pr

        public double dr_pr​(double x1,
                            double y1,
                            double x2,
                            double y2,
                            double x,
                            double y)
        Calculates the determinant of the given points.
        Parameters:
        x1 - the x-coordinate of the first point
        y1 - the y-coordinate of the first point
        x2 - the x-coordinate of the second point
        y2 - the y-coordinate of the second point
        x - the x-coordinate of the third point
        y - the y-coordinate of the third point
        Returns:
        the determinant value
      • eqdistance

        public TMono eqdistance​(CPoint p1,
                                CPoint p2,
                                CPoint p3,
                                CPoint p4)
        Creates a TMono object representing the equality of distances between two pairs of points.
        Parameters:
        p1 - the first point of the first pair
        p2 - the second point of the first pair
        p3 - the first point of the second pair
        p4 - the second point of the second pair
        Returns:
        the created TMono object
      • compareLN

        public boolean compareLN​(CLine ln1,
                                 CLine ln2)
        Compares two lines based on the ID of their first points.
        Parameters:
        ln1 - the first line
        ln2 - the second line
        Returns:
        true if the first point of the first line has a greater ID than the first point of the second line, false otherwise
      • parseTMonoString

        public TMono parseTMonoString​(java.lang.String name,
                                      java.lang.String func,
                                      int x)
        Parses a TMono object from a string representation.
        Parameters:
        name - the name of the TMono object
        func - the function string
        x - the x-coordinate
        Returns:
        the parsed TMono object
      • addZeron

        public boolean addZeron​(TMono m1)
        Adds a zero coefficient to the TMono object if its length is 1.
        Parameters:
        m1 - the TMono object
        Returns:
        true if a zero coefficient was added, false otherwise