Skip to content

sakhadib/vmath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to MathVoyage!

mathVoyage is a Java toolkit offering versatile math functions. In this library, we tried to implement coordinate geometry, trigonometry, matrix operations, combinatorics, vector, number system module, and more. It streamlines mathematical tasks using several well-known algorithms, saving developer's time and ensuring precision in Java application

Team Voyagers

  1. Adib Sakhawat

  2. Tahsin Islam

  3. Takia Farhin

Installation

  • Step 1 : Download the binary file from here vmath/releases
  • Step 2 : Add dependency to the vmath.jar in your project
  • Step 3 : You are good to go. See documentation if you need

Download

Supervised by

Syed Rifat Raiyan

Lecturer

Department of Computer Science and Engineering

Islamic University of Technology

Key Features

Click on the links to see documentation

  1. Algebraic Module

  2. Trigonometry Module

  3. Matrix Module

  4. Vector Module

  5. Number System Module

  6. Coordinate Geometry Module

  7. Combinatorics

  8. Bit-wise Operation

Tools

Language : Java IDE : IntelliJ Idea Version Control : Git Documentation : JavaDoc , Readme

Algebraic Module

01. double floor(double number)

It returns the floor of a double type number. The time complexity of this function is $O(1)$

Sample Input: $3.14$

Sample Output: $3.00$


02. Comparable min(Comparable num1, Comparable num2)

It returns the minimum value between two comparable type inputs. The time complexity of this function is $O(1)$

Sample Input: $7$, $13$

Sample Output: $7$


Sample Input: $7.15 ,$ $7.11$

Sample Output: $7.11$


03. Comparable min(Comparable[] array)

It returns the minimum value of an array. The time complexity of this function is $O(n)$

Sample Input: ${1, 5, 2, 4, 7, 3, 9, 8, 6, 10}$

Sample Output: $1$


04. Comparable argmin(Comparable[] array)

It returns the index of the minimum value of an array. The time complexity of this function is $O(n)$

Sample Input: ${1, 5, 2, 4, 7, 3, 9, 8, 6, 10}$

Sample Output: $0$


05. Comparable max(Comparable num1, Comparable num2)

It returns the maximum value between two comparable type inputs. The time complexity of this function is $O(1)$

Sample Input: $7$, $13$

Sample Output: $13$


Sample Input: $7.15$, $7.11$

Sample Output: $7.15$


06. Comparable max(Comparable[] array)

It returns the maximum value of an array. The time complexity of this function is $O(n)$

Sample Input: ${1, 5, 2, 4, 7, 3, 9, 8, 6, 10}$

Sample Output: $10$


07. Comparable argmax(Comparable[] array)

It returns the index of the maximum value of an array. The time complexity of this function is $O(n)$

Sample Input: ${1, 5, 2, 4, 7, 3, 9, 8, 6, 10}$

Sample Output: $9$


08. double pow(Comparable base, int exponent)

It calculates the power of a number. The time complexity of this function is $O(1)$

Sample Input: $3$, $4$

Sample Output: $81.0$


09. double sqrt(Comparable number)

It calculates the square root of a number. The time complexity of this function is $O(log(n))$

Sample Input: $16$

Sample Output: $4.0$


10. double cubeRoot(Comparable number)

It calculates the cube root of a number. The time complexity of this function is $O(log(n))$

Sample Input: $27$

Sample Output: $3.0$


11. double nthRoot(Comparable number)

It calculates the $n^{th}$ root of a number. The time complexity of this function is $O(log(n))$

Sample Input: $64, 6$

Sample Output: $2.0$


12. int abs(int number)

It returns the absolute value of an integer-type number. The time complexity of this function is $O(1)$

Sample Input: $-5$

Sample Output: $5$


13. double abs(double number)

It returns the absolute value of a double-type number. The time complexity of this function is $O(1)$

Sample Input: $-5.69$

Sample Output: $5.69$


14. double factorial(int number)

It returns the factorial of a number. The time complexity of this function is $O(n)$

Sample Input: $5$

Sample Output: $120.0$


15. int gcd(int num1, int num2)

It returns the greatest common divisor between two integer-type numbers. The time complexity of this function is $O(log(n))$

Sample Input: $12, 18$

Sample Output: $6$


Number Theory Module

01. double binToDec(String bineryNumber)

It converts a binary number (string) to a decimal number (double). The time complexity of this function is $O(n)$.

Sample Input: $1010$

Sample Output: $10.0$


02. String decToBin(double decimalNumber)

It converts a decimal number (double) to a binary number (string). The time complexity of this function is $O(n)$.

Sample Input: $10$

Sample Output: $1010$


03. String decToHex(double decimalNumber)

It converts a decimal number (double) to a Hexadecimal number (string). The time complexity of this function is $O(n)$.

Sample Input: $10$

Sample Output: $A$


04. double hexToDec(String hexadecimalString)

It converts a Hexadecimal number (string) to a decimal number (double). The time complexity of this function is $O(n)$.

Sample Input: $A$

Sample Output: $10.0$


05. double octToDec(String octalString)

It converts an Octal number (String) to a Decimal number (double). The time complexity of this function is $O(n)$.

Sample Input: $12$

Sample Output: $10.0$


06. String decToOct(double decimalNumber)

It converts a decimal number (double) to an Octal number (string). The time complexity of this function is $O(n)$.

Sample Input: $10$

Sample Output: $12$


07. String decToN(double decimalNumber, int base)

It converts a decimal number (double) to a number of any base (string). The time complexity of this function is $O(n)$.

Sample Input: $10, 6$

Sample Output: $14$


08. double nToDec(String number, int base)

It converts a number of any base (string) to a decimal number (double). The time complexity of this function is $O(n)$.

Sample Input: $14, 6$

Sample Output: $10.0$


09. String binToOct(String binaryString)

It converts a binary number (string) to an Octal number (string). The time complexity of this function is $O(n)$.

Sample Input: $1010$

Sample Output: $12$


10. String octToBin(String octalString)

It converts an Octal number (string) to a binary number (string). The time complexity of this function is $O(n)$.

Sample Input: $12$

Sample Output: $1010$


11. String binToHex(String binaryString)

It converts a binary number (string) to a Hexadecimal number (string). The time complexity of this function is $O(n)$.

Sample Input: $1010$

Sample Output: $A$


12. String hexToBin(String hexadecimalString)

It converts a Hexadecimal number (string) to a binary number (string). The time complexity of this function is $O(n)$.

Sample Input: $A$

Sample Output: $1010$


13. String binToN(String binaryString, int base)

It converts a binary number (string) to a number of any base (string). The time complexity of this function is $O(n)$.

Sample Input: $1010$

Sample Output: $14$


14. String octToHex(String octalString)

It converts an Octal number (string) to a Hexadecimal number (string). The time complexity of this function is $O(n)$.

Sample Input: $12$

Sample Output: $A$


15. String hexToOct(String hexadecimalString)

It converts a Hexadecimal number (string) to an Octal number (string). The time complexity of this function is $O(n)$.

Sample Input: $A$

Sample Output: $12$


16. String octToN(String octalString, int base)

It converts an Octal number (string) to a number of any base (string). The time complexity of this function is $O(n)$.

Sample Input: $12$

Sample Output: $14$


17. String hexToN(String hexadecimalString, int base)

It converts a Hexadecimal number (string) to a number of any base (string). The time complexity of this function is $O(n)$.

Sample Input: $A$

Sample Output: $14$


18. String nToK(String number, int base1, int base2)

It converts a number of any base $n$ (string) to a number of any base $k$ (string). The time complexity of this function is $O(n)$.

Sample Input: $``8", 10, 8$

Sample Output: $10$

Trigonometry Module

01. double degreeToRadian(double angleDegree)

It converts an angle from the Sexagesimal to the Circular unit. The time complexity of this function is $O(1)$.

Sample Input: $30$

Sample Output: $0.5235987755982988$


02. double radianToDegree(double angleRadian)

It converts an angle from the Circular to the Sexagesimal unit. The time complexity of this function is $O(1)$.

Sample Input: $\pi/6$

Sample Output: $29.999999999999996$


03. double sin(double angle, Angle unit)

It returns the sine of an angle given in radians or degrees. The time complexity of this function is $O(n)$.

Sample Input: $30, Angle.DEGREE$

Sample Output: $0.49999999999999994$

Sample Input: $0.523599, Angle.RADIAN$

Sample Output: $0.49999999999999994$


04. double cos(double angle, Angle unit)

It returns the cosine of an angle given in radians or degrees. The time complexity of this function is $O(n)$.

Sample Input: $30, Angle.DEGREE$

Sample Output: $0.8660254037844386$

Sample Input: $0.523599, Angle.RADIAN$

Sample Output: $0.8660254037844386$


05. double tan(double angle, Angle unit)

It returns the tangent of an angle given in radians or degrees. The time complexity of this function is $O(n)$.

Sample Input: $30, Angle.DEGREE$

Sample Output: $0.5773502691896257$

Sample Input: $0.523599, Angle.RADIAN$

Sample Output: $0.5773502691896257$


06. double cot(double angle, Angle unit)

It returns the cotangent of an angle given in radians or degrees. The time complexity of this function is $O(n)$.

Sample Input: $30, Angle.DEGREE$

Sample Output: $1.7320508075688774$

Sample Input: $0.523599, Angle.RADIAN$

Sample Output: $1.7320508075688774$


07. double sec(double angle, Angle unit)

It returns the secant of an angle given in radians or degrees. The time complexity of this function is $O(n)$.

Sample Input: $30, Angle.DEGREE$

Sample Output: $1.1547005383792517$

Sample Input: $0.523599, Angle.RADIAN$

Sample Output: $1.1547005383792517$


08. double cosec(double angle, Angle unit)

It returns the cosecant of an angle given in radians or degrees. The time complexity of this function is $O(n)$.

Sample Input: $30, Angle.DEGREE$

Sample Output: $2.0000000000000004$

Sample Input: $0.523599, Angle.RADIAN$

Sample Output: $2.0000000000000004$


09. double arcsin(double number, Angle unit)

It returns the arc sin of a number in the preferred unit. The time complexity of this function is $O(n)$.

Sample Input: $0.5, Angle.DEGREE$

Sample Output: $30.0$

Sample Input: $0.5, Angle.RADIAN$

Sample Output: $0.523598775598299$


10. double arccos(double number, Angle unit)

It returns the arc cos of a number in the preferred unit. The time complexity of this function is $O(n)$.

Sample Input: $0.5, Angle.DEGREE$

Sample Output: $60.0$

Sample Input: $0.5, Angle.RADIAN$

Sample Output: $1.0471975511965974$


11. double arctan(double number, Angle unit)

It returns the arc tan of a number in the preferred unit. The time complexity of this function is $O(n)$.

Sample Input: $\sqrt3, Angle.DEGREE$

Sample Output: $60.0$

Sample Input: $\sqrt3, Angle.RADIAN$

Sample Output: $1.0471975511965976$


12. double arccot(double number, Angle unit)

It returns the arc cot of a number in the preferred unit. The time complexity of this function is $O(n)$.

Sample Input: $\sqrt3, Angle.DEGREE$

Sample Output: $30.0$

Sample Input: $\sqrt3, Angle.RADIAN$

Sample Output: $0.5235987755982989$


13. double arcsec(double number, Angle unit)

It returns the arc sec of a number in the preferred unit. The time complexity of this function is $O(n)$.

Sample Input: $2, Angle.DEGREE$

Sample Output: $30.0$

Sample Input: $2, Angle.RADIAN$

Sample Output: $0.523598775598299$


14. double arccosec(double number, Angle unit)

It returns the arc cosec of a number in the preferred unit. The time complexity of this function is $O(n)$.

Sample Input: $2, Angle.DEGREE$

Sample Output: $60.0$

Sample Input: $2, Angle.RADIAN$

Sample Output: $1.0471975511965974$

Combinatorics Module

01. double combination(int n, int r)

It returns the number of ways of choosing $r$ objects from $n$ objects. The time complexity of this function is $O(n)$.

Sample Input: $5, 2$

Sample Output: $10.0$


02. double permutation(int n, int r)

It returns the number of ways of choosing $r$ objects from $n$ objects when the order matters. The time complexity of this function is $O(n)$.

Sample Input: $5, 2$

Sample Output: $20.0$


03. double numberOfSubsets(int n)

It returns the number of subsets of a set of $n$ elements. The time complexity of this function is $O(n)$.

Sample Input: $5$

Sample Output: $32.0$


04. ArrayList<ArrayList<Integer>> generateSubsets(Integer[] set)

It returns all the subsets of a set. The time complexity of this function is $O(2^n)$.

Sample Input: ${1, 2, 3}$

Sample Output: ${{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}$

Matrix Module

01. Matrix add(Matrix a, Matrix b)

It returns the sum of two matrices. The time complexity of this function is $O(n^2)$.

Sample Input: $\begin{bmatrix}2 & 1 & 1\1 & 3 & 2\1 & 2 & 4\end{bmatrix}, \begin{bmatrix}9 & 8 & 7\7 & 6 & 5\5 & 4 & 3\end{bmatrix}$

Sample Output: $\begin{bmatrix}11 & 9 & 8\8 & 9 & 7\6 & 6 & 7\end{bmatrix}$


02. Matrix subtract(Matrix a, Matrix b)

It returns the difference of two matrices. The time complexity of this function is $O(n^2)$.

Sample Input: $\begin{bmatrix}9 & 8 & 7\\7 & 6 & 5\\5 & 4 & 3\end{bmatrix} , \begin{bmatrix}2 & 1 & 1\\1 & 3 & 2\\1 & 2 & 4\end{bmatrix}$

Sample Output: $\begin{bmatrix}7 & 7 & 6\\6 & 3 & 3\\4 & 2 & -1\end{bmatrix}$


03. Matrix multiply(Matrix a, Matrix b)

It returns the product of two matrices. The time complexity of this function is $O(n^3)$.

Sample Input: $\begin{bmatrix}2 & 1 & 1\1 & 3 & 2\1 & 2 & 4\end{bmatrix}, \begin{bmatrix}9 & 8 & 7\7 & 6 & 5\5 & 4 & 3\end{bmatrix}$

Sample Output: $\begin{bmatrix}30 & 26 & 22\40 & 34 & 28\43 & 36 & 29\end{bmatrix}$


04. Matrix multiply(Matrix a, double scalar)

It returns the product of a matrix and a scalar. The time complexity of this function is $O(n^2)$.

Sample Input: $\begin{bmatrix}2 & 1 & 1\1 & 3 & 2\1 & 2 & 4\end{bmatrix}, 2$

Sample Output: $\begin{bmatrix}4 & 2 & 2\2 & 6 & 4\2 & 4 & 8\end{bmatrix}$


05. Matrix transpose(Matrix a)

It returns the transpose of a matrix. The time complexity of this function is $O(n^2)$.

Sample Input: $\begin{bmatrix}2 & 1 & 1\1 & 3 & 2\1 & 2 & 4\end{bmatrix}$

Sample Output: $\begin{bmatrix}2 & 1 & 1\1 & 3 & 2\1 & 2 & 4\end{bmatrix}$


06. Matrix inverse(Matrix a)

It returns the inverse of a matrix. The time complexity of this function is $O(n^3)$.

Sample Input: $\begin{bmatrix}2 & 1 & 1\1 & 3 & 2\1 & 2 & 4\end{bmatrix}$

Sample Output: $\begin{bmatrix}8/13 & -2/13 & -1/13\-2/13 & 7/13 & -3/13\-1/13 & -3/13 & 5/13\end{bmatrix}$


07. double determinant(Matrix a)

It returns the determinant of a matrix. The time complexity of this function is $O(n^3)$.

Sample Input: $\begin{bmatrix}2 & 1 & 1\1 & 3 & 2\1 & 2 & 4\end{bmatrix}$

Sample Output: $13.0$


08. Matrix ones(int rows, int cols)

It returns a matrix of ones. The time complexity of this function is $O(n^2)$.

Sample Input: $3, 3$

Sample Output: $\begin{bmatrix}1 & 1 & 1\1 & 1 & 1\1 & 1 & 1\end{bmatrix}$


09. Matrix zeros(int rows, int cols)

It returns a matrix of zeros. The time complexity of this function is $O(n^2)$.

Sample Input: $3, 3$

Sample Output: $\begin{bmatrix}0 & 0 & 0\0 & 0 & 0\0 & 0 & 0\end{bmatrix}$


10. Matrix identity(int n)

It returns an identity matrix. The time complexity of this function is $O(n^2)$.

Sample Input: $3$

Sample Output: $\begin{bmatrix}1 & 0 & 0\0 & 1 & 0\0 & 0 & 1\end{bmatrix}$


11. boolean compare(Matrix a, Matrix b)

It returns true if two matrices are equal. The time complexity of this function is $O(n^2)$.

Sample Input: $\begin{bmatrix}2 & 1 & 1\1 & 3 & 2\1 & 2 & 4\end{bmatrix}, \begin{bmatrix}2 & 1 & 1\1 & 3 & 2\1 & 2 & 4\end{bmatrix}$

Sample Output: $true$


12. Matrix pow(Matrix a, int power)

It returns the power of a matrix. The time complexity of this function is $O(n^3)$.

Sample Input: $\begin{bmatrix}2 & 1 & 1\1 & 3 & 2\1 & 2 & 4\end{bmatrix}, 2$

Sample Output: $\begin{bmatrix}6 & 7 & 8\7& 14 & 15\8 & 15 & 21\end{bmatrix}$

Vector Module

01. Vector add(Vector a, Vector b)

It returns the sum of two vectors. The time complexity of this function is $O(n)$.

Sample Input: $\begin{bmatrix}1\2\3\end{bmatrix}, \begin{bmatrix}4\5\6\end{bmatrix}$

Sample Output: $\begin{bmatrix}5\7\9\end{bmatrix}$


02. Vector subtract(Vector a, Vector b)

It returns the difference of two vectors. The time complexity of this function is $O(n)$.

Sample Input: $\begin{bmatrix}4\5\6\end{bmatrix}, \begin{bmatrix}1\2\3\end{bmatrix}$

Sample Output: $\begin{bmatrix}3\3\3\end{bmatrix}$


03. double scalerProduct(vector a, vector b)

It returns the dot product of two vectors. The time complexity of this function is $O(n)$.

Sample Input: $\begin{bmatrix}1\2\3\end{bmatrix}, \begin{bmatrix}4\5\6\end{bmatrix}$

Sample Output: $32.0$


04. vector vectorProduct(vector a, vector b)

It returns the cross product of two vectors. The time complexity of this function is $O(n)$.

Sample Input: $\begin{bmatrix}1\2\3\end{bmatrix}, \begin{bmatrix}4\5\6\end{bmatrix}$

Sample Output: $\begin{bmatrix}-3.0\6.0\-3.0\end{bmatrix}$


05. vector multiply(vector a, Matrix m)

It returns the product of a vector and a matrix. The time complexity of this function is $O(n^2)$.

Sample Input: $\begin{bmatrix}1\2\3\end{bmatrix}, \begin{bmatrix}2 & 1 & 1\1 & 3 & 2\1 & 2 & 4\end{bmatrix}$

Sample Output: $\begin{bmatrix}7\13\17\end{bmatrix}$


06. boolean compare(vector a, vector b)

It returns true if two vectors are equal. The time complexity of this function is $O(n)$.

Sample Input: $\begin{bmatrix}1\2\3\end{bmatrix}, \begin{bmatrix}1\2\3\end{bmatrix}$

Sample Output: $true$


07. double magnitude(vector a)

It returns the magnitude of a vector. The time complexity of this function is $O(n)$.

Sample Input: $\begin{bmatrix}1\2\3\end{bmatrix}$

Sample Output: $3.7416573867739413$


08. vector unitVector(vector a)

It returns the unit vector of a vector. The time complexity of this function is $O(n)$.

Sample Input: $\begin{bmatrix}1\2\3\end{bmatrix}$

Sample Output: $\begin{bmatrix}0.2672612419124244\0.5345224838248488\0.8017837257372732\end{bmatrix}$

Geometry Module

01. double distance(Point p1, Point p2, DistanceType c)

It returns the distance between two points. The time complexity of this function is $O(1)$.

Sample Input: $(1, 2), (3, 4), DistanceType.EUCLIDEAN$

Sample Output: $2.8284271247461903$


02. double slope(Point p1, Point p2)

It returns the slope of a line passing through two points. The time complexity of this function is $O(1)$.

Sample Input: $(1, 2), (3, 4)$

Sample Output: $1.0$


03. Point midpoint(Point p1, Point p2)

It returns the midpoint of a line passing through two points. The time complexity of this function is $O(1)$.

Sample Input: $(1, 2), (3, 4)$

Sample Output: $(2.0, 3.0)$


04. Point centroid(Point p1, Point p2, Point p3)

It returns the centroid of a triangle passing through three points. The time complexity of this function is $O(1)$.

Sample Input: $(1, 2), (3, 4), (5, 6)$

Sample Output: $(3.0, 4.0)$


05. double areaOfTriangle(Point p1, Point p2, Point p3)

It returns the area of a triangle given three points. The time complexity of this function is $O(1)$.

Sample Input: $(1, 1), (1, 4), (5, 6)$

Sample Output: $6.0$


06. Point interleaverPoint(Point p1, Point p2, double m, double n)

It returns the interleave point of two points that divide the connecting line in m:n. The time complexity of this function is $O(1)$.

Sample Input: $(2, 0), (7, 5), 2, 3$

Sample Output: $(4.0, 2.0)$


07. Point externalizerPoint(Point p1, Point p2, double m, double n)

It returns the external point of two points that divide the connecting line in m:n. The time complexity of this function is $O(1)$.

Sample Input: $(-2, 3), (6, -8), 1, 2$

Sample Output: $(-10.0, 14.0)$


08. double areaOfCircle(Point p1, Point p2)

It returns the area of a circle given two endpoints of the radius. The time complexity of this function is $O(1)$.

Sample Input: $(1, 1), (1, 3)$

Sample Output: $12.5663706143592$


09. double circumferenceOfCircle(Point p1, Point p2)

It returns the circumference of a circle given two endpoints of the radius. The time complexity of this function is $O(1)$.

Sample Input: $(1, 1), (1, 3)$

Sample Output: $12.566370614359187$


10. boolean isTriangle(Point p1, Point p2, Point p3, triangleType c)

It returns true if three points form a triangle. The time complexity of this function is $O(1)$.

Sample Input: $(1, 1), (1, 3), (3, 1), triangleType.ISOSCELES$

Sample Output: $true$


11. double angleBetweenTwoSlopes(double m1, double m2)

It returns the angle between two slopes. The time complexity of this function is $O(1)$.

Sample Input: $1.0, 2.0$

Sample Output: $45.0\degree$


12. boolean isQuadrilateral(Point p1, Point p2, Point p3, Point p4, quadrilateralType c)

It returns true if four points form a quadrilateral. The time complexity of this function is $O(1)$.

Sample Input: $(1, 1), (1, 3), (3, 1), (3, 3), quadrilateralType.RECTANGLE$

Sample Output: $true$


13. boolean isLine(Line l1, Line l2, lineType c)

It returns true if two lines are parallel, perpendicular or same. The time complexity of this function is $O(1)$.

Sample Input: $(1,2,3) , (2,4,6), lineType.SAME$

Sample Output: $true$


14. boolean areThreeLinesSame(Line l1, Line l2, Line l3)

It returns true if three lines are same. The time complexity of this function is $O(1)$.

Sample Input: $(1,2,3) , (2,4,6), (3,6,9)$

Sample Output: $true$


15. Point intersectionOfTwoLines(Line l1, Line l2)

It returns the intersection point of two lines. The time complexity of this function is $O(1)$.

Sample Input: $(1,2,3) , (1,-5,6)$

Sample Output: $(3.0, 0.0)$


16. double slope(Line l)

It returns the slope of a line. The time complexity of this function is $O(1)$.

Sample Input: $(1,2,3)$

Sample Output: $-0.3333333333333333$


17. double distanceBetweenTwoParallelLines(Line l1, Line l2)

It returns the distance between two parallel lines. The time complexity of this function is $O(1)$.

Sample Input: $(2,3,4) , (1,1)$

Sample Output: $2.4961508$


19. Line getPerpendicularLine(Line l, Point p)

It returns the perpendicular line of a line that goes through the point. The time complexity of this function is $O(1)$.

Sample Input: $(3,12,-7) , (2,5)$

Sample Output: $(12.0, -3.0, -9.0)$


20. Line getParallelLine(Line l, Point p)

It returns the parallel line of a line that goes through the point. The time complexity of this function is $O(1)$.

Sample Input: $(2, 11, -2) , (4, -3)$

Sample Output: $(2.0, 11.0, 25.0)$


21. Line getLineFromIntersectionPoint(Line l1, Line l2)

It returns the line that goes through the intersection point of two lines. The time complexity of this function is $O(1)$.

Sample Input: $(2, 11, -2) , (3, 12, -7)$

Sample Output: $(54.99, 222.99, -125.66)$


22. double areaOfQuadrilateral(Line l1, Line l2, Line l3, Line l4)

It returns the area of a quadrilateral given four lines. The time complexity of this function is $O(1)$.

Sample Input: $(4,-3,7) , (3,-4,21), (4,-3,0), (3,-4,14)$

Sample Output: $7.0$


23. double areaOfQuadrilateral(Point p1, Point p2, Point p3, Point p4)

It returns the area of a quadrilateral given four points. The time complexity of this function is $O(1)$.

Sample Input: $(6,8), (2,5), (5,9), (9,12)$

Sample Output: $7.0$


24. double areaOfTriangle(Line l1, Line l2, Line l3)

It returns the area of a triangle given three lines. The time complexity of this function is $O(1)$.

Sample Input: $(4,-3,7) , (1,1,-14), (3,-4,14)$

Sample Output: $3.5$


25. double areaOfConvexPolygon(Point[] points)

It returns the area of a convex polygon given its vertices. The time complexity of this function is $O(n)$.

Sample Input: ${(1,1), (1,5), (5,5), (5,1)}$

Sample Output: $16.0$


26. boolean isPointInPolygon(Point[] points, Point p)

It returns true if a point is inside a polygon. The time complexity of this function is $O(n)$.

Sample Input: ${(1,1), (1,5), (5,5), (5,1)}, (2,2)$

Sample Output: $true$

Bit-wise Operation Module

01. int and(int a, int b)

It returns the bitwise and of two numbers. The time complexity of this function is $O(1)$.

Sample Input: $5, 6$

Sample Output: $4$


02. int or(int a, int b)

It returns the bitwise or of two numbers. The time complexity of this function is $O(1)$.

Sample Input: $5, 6$

Sample Output: $7$


03. int xor(int a, int b)

It returns the bitwise xor of two numbers. The time complexity of this function is $O(1)$.

Sample Input: $5, 6$

Sample Output: $3$


04. int not(int a)

It returns the bitwise not of a number. The time complexity of this function is $O(1)$.

Sample Input: $5$

Sample Output: $-6$


05. int leftShift(int a, int b)

It returns the bitwise left shift of a number. The time complexity of this function is $O(1)$.

Sample Input: $5, 2$

Sample Output: $20$


06. int rightShift(int a, int b)

It returns the bitwise right shift of a number. The time complexity of this function is $O(1)$.

Sample Input: $5, 2$

Sample Output: $1$


07. String zeroFillRightShift(int a, int b)

It returns the zero fill right shift of a number. The time complexity of this function is $O(1)$.

Sample Input: $5, 2$

Sample Output: $1$