Initial commit.
This commit is contained in:
10
src/main/java/fr/insa/gei/App.java
Normal file
10
src/main/java/fr/insa/gei/App.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package fr.insa.gei;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*/
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
||||
73
src/main/java/fr/insa/gei/angles/IAngle.java
Normal file
73
src/main/java/fr/insa/gei/angles/IAngle.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package fr.insa.gei.angles;
|
||||
|
||||
public interface IAngle extends Comparable<IAngle> {
|
||||
|
||||
/**
|
||||
* Get the value of this angle in degrees.
|
||||
*
|
||||
* @return the value of this angle in degrees.
|
||||
*/
|
||||
double toDegrees();
|
||||
|
||||
/**
|
||||
* Get the value of this angle in radians.
|
||||
*
|
||||
* @return the value of this angle in radians.
|
||||
*/
|
||||
double toRadians();
|
||||
|
||||
/**
|
||||
* Get the cosine of this angle.
|
||||
*
|
||||
* @return the cosine of this angle.
|
||||
*/
|
||||
double cos();
|
||||
|
||||
/**
|
||||
* Get the sine of this angle.
|
||||
*
|
||||
* @return the sine of this angle.
|
||||
*/
|
||||
double sin();
|
||||
|
||||
/**
|
||||
* Get the tangent of this angle.
|
||||
*
|
||||
* @return the tangent of this angle.
|
||||
*/
|
||||
double tan();
|
||||
|
||||
/**
|
||||
* Add another angle to this angle.
|
||||
*
|
||||
* @param other The other angle to add.
|
||||
* @return a new angle representing the sum of this angle and the other angle.
|
||||
*/
|
||||
IAngle add(IAngle other);
|
||||
|
||||
/**
|
||||
* Subtract another angle from this angle.
|
||||
*
|
||||
* @param other The other angle to subtract.
|
||||
* @return a new angle representing the difference between this angle and the
|
||||
* other angle.
|
||||
*/
|
||||
IAngle sub(IAngle other);
|
||||
|
||||
/**
|
||||
* Multiply this angle by a factor.
|
||||
*
|
||||
* @param factor The factor to multiply by.
|
||||
* @return a new angle representing this angle multiplied by the factor.
|
||||
*/
|
||||
IAngle mul(double factor);
|
||||
|
||||
/**
|
||||
* Divide this angle by a divisor.
|
||||
*
|
||||
* @param divisor The divisor to divide by.
|
||||
* @return a new angle representing this angle divided by the divisor.
|
||||
*/
|
||||
IAngle div(double divisor);
|
||||
|
||||
}
|
||||
66
src/main/java/fr/insa/gei/angles/IAngleFactory.java
Normal file
66
src/main/java/fr/insa/gei/angles/IAngleFactory.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package fr.insa.gei.angles;
|
||||
|
||||
public interface IAngleFactory<Angle extends IAngle> {
|
||||
|
||||
/**
|
||||
* Construct a new Angle object using the given value in radians.
|
||||
*
|
||||
* @param radians Value of the angle in radians.
|
||||
* @return a new Angle object.
|
||||
*/
|
||||
public Angle fromRadians(double radians);
|
||||
|
||||
/**
|
||||
* Construct a new Angle object using the given value in degrees.
|
||||
*
|
||||
* @param degrees Value of the angle in degrees.
|
||||
* @return a new Angle object.
|
||||
*/
|
||||
public Angle fromDegrees(double degrees);
|
||||
|
||||
/**
|
||||
* Construct a new Angle object corresponding to the arc cosine of the given
|
||||
* value.
|
||||
*
|
||||
* @param a Value for which to compute the arc cosine.
|
||||
* @return a new Angle object.
|
||||
*/
|
||||
public default Angle acos(double a) {
|
||||
return fromRadians(Math.acos(a));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Angle object corresponding to the arc sine of the given
|
||||
* value.
|
||||
*
|
||||
* @param a Value for which to compute the arc sine.
|
||||
* @return a new Angle object.
|
||||
*/
|
||||
public default Angle asin(double a) {
|
||||
return fromRadians(Math.asin(a));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Angle object corresponding to the arc tangent of the given
|
||||
* value.
|
||||
*
|
||||
* @param a Value for which to compute the arc tangent.
|
||||
* @return a new Angle object.
|
||||
*/
|
||||
public default Angle atan(double a) {
|
||||
return fromRadians(Math.atan(a));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Angle object corresponding to the arc tangent of the given
|
||||
* values.
|
||||
*
|
||||
* @param y Value for which to compute the arc tangent.
|
||||
* @param x Value for which to compute the arc tangent.
|
||||
* @return a new Angle object.
|
||||
*/
|
||||
public default Angle atan2(double y, double x) {
|
||||
return fromRadians(Math.atan2(y, x));
|
||||
}
|
||||
|
||||
}
|
||||
104
src/main/java/fr/insa/gei/fractions/IFraction.java
Normal file
104
src/main/java/fr/insa/gei/fractions/IFraction.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package fr.insa.gei.fractions;
|
||||
|
||||
public interface IFraction extends Comparable<IFraction> {
|
||||
|
||||
/**
|
||||
* Get the numerator of this fraction in lowest term.
|
||||
*
|
||||
* @return the numerator of this fraction in lowest term.
|
||||
*/
|
||||
public int getNumerator();
|
||||
|
||||
/**
|
||||
* Get the denominator of this fraction in lowest term.
|
||||
*
|
||||
* @return the denominator of this fraction in lowest term.
|
||||
*/
|
||||
public int getDenominator();
|
||||
|
||||
/**
|
||||
* Add another fraction to this fraction.
|
||||
*
|
||||
* @param f the fraction to add
|
||||
* @return the result of the addition
|
||||
*/
|
||||
public IFraction add(IFraction f);
|
||||
|
||||
/**
|
||||
* Add an integer value to this fraction.
|
||||
*
|
||||
* @param value the integer value to add
|
||||
* @return the result of the addition
|
||||
*/
|
||||
public IFraction add(int value);
|
||||
|
||||
/**
|
||||
* Subtract another fraction from this fraction.
|
||||
*
|
||||
* @param f the fraction to subtract
|
||||
* @return the result of the subtraction
|
||||
*/
|
||||
public IFraction sub(IFraction f);
|
||||
|
||||
/**
|
||||
* Subtract an integer value from this fraction.
|
||||
*
|
||||
* @param value the integer value to subtract
|
||||
* @return the result of the subtraction
|
||||
*/
|
||||
public IFraction sub(int value);
|
||||
|
||||
/**
|
||||
* Multiply this fraction by another fraction.
|
||||
*
|
||||
* @param f the fraction to multiply by
|
||||
* @return the result of the multiplication
|
||||
*/
|
||||
public IFraction mul(IFraction f);
|
||||
|
||||
/**
|
||||
* Multiply this fraction by an integer value.
|
||||
*
|
||||
* @param value the integer value to multiply by
|
||||
* @return the result of the multiplication
|
||||
*/
|
||||
public IFraction mul(int value);
|
||||
|
||||
/**
|
||||
* Divide this fraction by another fraction.
|
||||
*
|
||||
* @param f the fraction to divide by
|
||||
* @return the result of the division
|
||||
*/
|
||||
public IFraction div(IFraction f);
|
||||
|
||||
/**
|
||||
* Divide this fraction by an integer value.
|
||||
*
|
||||
* @param value the integer value to divide by
|
||||
* @return the result of the division
|
||||
*/
|
||||
public IFraction div(int value);
|
||||
|
||||
/**
|
||||
* Invert this fraction.
|
||||
*
|
||||
* @return the inverted fraction
|
||||
*/
|
||||
public IFraction inv();
|
||||
|
||||
/**
|
||||
* Negate this fraction.
|
||||
*
|
||||
* @return the negated fraction
|
||||
*/
|
||||
public IFraction neg();
|
||||
|
||||
/**
|
||||
* Convert this fraction to a double value.
|
||||
*
|
||||
* @return the double value of this fraction
|
||||
*/
|
||||
public double toDouble();
|
||||
|
||||
}
|
||||
24
src/main/java/fr/insa/gei/fractions/IFractionFactory.java
Normal file
24
src/main/java/fr/insa/gei/fractions/IFractionFactory.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package fr.insa.gei.fractions;
|
||||
|
||||
public interface IFractionFactory<Fraction extends IFraction> {
|
||||
|
||||
/**
|
||||
* Creates a fraction with given numerator and denominator.
|
||||
*
|
||||
* @param numerator the numerator of the fraction
|
||||
* @param denominator the denominator of the fraction
|
||||
* @return a new fraction instance
|
||||
*/
|
||||
public Fraction create(int numerator, int denominator);
|
||||
|
||||
/**
|
||||
* Creates a fraction with given numerator and denominator equal to 1.
|
||||
*
|
||||
* @param numerator the numerator of the fraction
|
||||
* @return a new fraction instance
|
||||
*/
|
||||
public default Fraction create(int numerator) {
|
||||
return this.create(numerator, 1);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user