Skip to content

Commit

Permalink
Merge pull request #4 from andreww1011/v1.2.1
Browse files Browse the repository at this point in the history
v1.2.1
  • Loading branch information
andreww1011 authored Oct 5, 2022
2 parents f77ee33 + ed1c4b5 commit 9791dce
Show file tree
Hide file tree
Showing 39 changed files with 3,930 additions and 783 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# jmud
# <img src="https://repository-images.githubusercontent.com/325668576/94ce6095-c753-485e-a563-c98b0b434341" alt="jmud" width="320">
Java library for creating and manipulating dimensional units of measurement.

# BETA
This project is in development stage and is not for use in production. FOR EVALUATION USE ONLY.

## Usage

```java
Expand All @@ -19,12 +16,11 @@ Unit mile = Units.newUnit()

Expression distance = Expressions.take(7, mile);
Expression time = Expressions.take("16.09344", Units.MINUTE);
Expression speed = distance.divide(time);

Measure<DoubleField> speed = distance.divide(time)
.using(DoubleField.factory())
.as(kilometerPerHour);
Measure<DoubleField> m = speed.using(DoubleField.factory());

System.out.println(speed.toString()); //prints "42.0 kph"
System.out.println(m.as(kilometerPerHour).toString()); //prints "42.0 kph"
```

## Features
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.jamw.jmud</groupId>
<artifactId>jmud</artifactId>
<name>jmud</name>
<version>1.2.0-beta</version>
<version>1.2.1</version>
<packaging>jar</packaging>
<build>
<plugins>
Expand All @@ -19,6 +19,7 @@
<version>3.0.0-M7</version>
<configuration>
<includes>
<include>*Test.java</include>
<include>**/examples/*.java</include>
</includes>
</configuration>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/jamw/jmud/Composition.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public interface Composition extends Iterable<CompositionComponent> {
/**
* Returns the exponent of the specified fundamental dimension of this
* composition.
* @param fd Fundamental dimension in composition.
* @return Exponent corresponding to the specified fundamental dimension.
* @param fd fundamental dimension in composition.
* @return exponent corresponding to the specified fundamental dimension.
*/
Exponent getExponent(FundamentalDimension fd);

Expand All @@ -53,7 +53,7 @@ public interface Composition extends Iterable<CompositionComponent> {
* traversed by this iterator. Implementations should not rely on this method
* to return all possible fundamental dimensions. Modifying this composition
* via the iterator is not permitted.
* @return An iterator of composition components of this composition.
* @return an iterator of composition components of this composition.
*/
@Override
Iterator<CompositionComponent> iterator();
Expand All @@ -68,9 +68,9 @@ public interface Composition extends Iterable<CompositionComponent> {
* instance, the compositions <i>Q1 = [L<sup>2</sup>]</i> and
* <i>Q2 = [L<sup>2</sup>T<sup>0</sup>]</i> are, in fact, equal.
*
* @param o Object to be compared for equality to this composition.
* @param o object to be compared for equality to this composition.
*
* @return True if the specified object is equal to this composition.
* @return true if the specified object is equal to this composition.
*/
boolean equals(Object o);
}
5 changes: 3 additions & 2 deletions src/main/java/com/jamw/jmud/CompositionComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
/**
* One {@link FundamentalDimension fundamental dimension}-{@link Exponent exponent}
* pair contained in the set of pairs comprising a dimension's composition.
*
* @author andreww1011
*/
public interface CompositionComponent {
Expand All @@ -41,9 +42,9 @@ public interface CompositionComponent {
* composition components contain the same fundamental dimension
* and exponent.
*
* @param o Object to be compared for equality to this composition component.
* @param o object to be compared for equality to this composition component.
*
* @return True if the specified object is equal to this composition component.
* @return true if the specified object is equal to this composition component.
*/
@Override
public boolean equals(Object o);
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/com/jamw/jmud/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,28 @@

/**
* Factory class of common universal constants.
*
* @author andreww1011
*/
public abstract class Constants<F extends Field<F>> {

private Constants() {}

/**
* A scalar representing the number 0.
*/
public static final Scalar zero = Expressions.ZERO;

/**
* A scalar representing the number 1.
*/
public static final Scalar one = Expressions.ONE;

/**
* A scalar representing the decimal number 10.
*/
public static final Scalar ten = Expressions.TEN;

/**
* The ratio of the circumference of a circle to its diameter, <i>\u03C0</i>,
* defined as 3.141 592 653 589 793 238 462 643 383 279.
Expand All @@ -49,7 +65,7 @@ private Constants() {}

/**
* The reduced Planck constant, <i>\u0127</i>, defined as
* {@link #h h} / 2⋅\u03C0.
* {@link #h h} / 2⋅{@link pi \u03C0}.
*/
public static final Expression h_bar = h.divide(2).divide(pi);

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/jamw/jmud/Dimension.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public interface Dimension {
/**
* Asserts that the specified dimensions are commensurable.
*
* @param d1 Dimension to compare
* @param d2 Dimension to compare
* @param d1 dimension to compare
* @param d2 dimension to compare
*
* @throws IncommensurableDimensionException if the dimensions are not commensurable.
*/
Expand All @@ -78,12 +78,12 @@ static void assertCommensurable(Dimension d1, Dimension d2) throws Incommensurab
}

/**
* Returns the canonical name of this dimension.
* Returns the name of this dimension.
*/
String getName();

/**
* Returns the canonical symbol of this dimension.
* Returns the symbol of this dimension.
*/
String getSymbol();

Expand All @@ -96,7 +96,7 @@ static void assertCommensurable(Dimension d1, Dimension d2) throws Incommensurab
* Returns true if the specified dimension is commensurable with this
* dimension.
*
* @param d Dimension to be compared for commensurability with this dimension.
* @param d dimension to be compared to this dimension for commensurability .
*/
default boolean isCommensurable(Dimension d) {
if (this.equals(d))
Expand All @@ -111,7 +111,7 @@ default boolean isCommensurable(Dimension d) {
* Thus, this method returns true if and only if the
* specified object and this dimension are the same object.
*
* @param o Object to compare to this dimension.
* @param o object to compare to this dimension.
*/
@Override
boolean equals(Object o);
Expand Down
Loading

0 comments on commit 9791dce

Please sign in to comment.