1 package org.djunits.value.vdouble.scalar.base; 2 3 import org.djunits.unit.AbsoluteLinearUnit; 4 import org.djunits.unit.Unit; 5 import org.djunits.value.base.Scalar; 6 7 /** 8 * Double scalar functions. 9 * <p> 10 * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 11 * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>. 12 * </p> 13 * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a> 14 * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a> 15 * @author <a href="https://www.transport.citg.tudelft.nl">Wouter Schakel</a> 16 * @param <U> the unit for which this is the interface 17 * @param <S> the scalar type belonging to the unit 18 */ 19 public interface DoubleScalarInterface<U extends Unit<U>, S extends DoubleScalarInterface<U, S>> extends Scalar<U, S> 20 { 21 /** 22 * Retrieve the value in the underlying SI unit. 23 * @return double 24 */ 25 double getSI(); 26 27 /** 28 * Retrieve the value in the original unit. 29 * @return double 30 */ 31 double getInUnit(); 32 33 /** 34 * Retrieve the value converted into some specified unit. 35 * @param targetUnit U; the unit to convert the value into 36 * @return double 37 */ 38 double getInUnit(U targetUnit); 39 40 /** 41 * Methods for Relative DoubleScalar. 42 * <p> 43 * Copyright (c) 2019-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. 44 * <br> 45 * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>. 46 * <p> 47 * @author <a href="https://www.tudelft.nl/averbraeck" target="_blank">Alexander Verbraeck</a> 48 * @param <U> the unit 49 * @param <R> the relative scalar 50 */ 51 public interface Rel<U extends Unit<U>, R extends DoubleScalarInterface.Rel<U, R>> 52 extends DoubleScalarInterface<U, R>, Scalar.Rel<U, R> 53 { 54 /** 55 * Construct a new Relative Immutable DoubleScalar of the right type. Each extending class must implement this method. 56 * @param value double; the double value 57 * @param unit U; the unit 58 * @return R a new relative instance of the DoubleScalar of the right type 59 */ 60 R instantiateRel(double value, U unit); 61 } 62 63 /** 64 * Additional methods for Relative Scalar that has a corresponding Absolute Scalar. An example is the relative scalar Length 65 * that has a corresponding absolute scalar Position. 66 * <p> 67 * Copyright (c) 2019-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. 68 * <br> 69 * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>. 70 * <p> 71 * @author <a href="https://www.tudelft.nl/averbraeck" target="_blank">Alexander Verbraeck</a> 72 * @param <AU> the absolute unit belonging to the absoluteunit 73 * @param <A> the absolute scalar belonging to the relative scalar 74 * @param <RU> the absolute unit belonging to the relative unit 75 * @param <R> the relative scalar belonging to the absolute scalar 76 */ 77 public interface RelWithAbs<AU extends AbsoluteLinearUnit<AU, RU>, A extends DoubleScalarInterface.Abs<AU, A, RU, R>, 78 RU extends Unit<RU>, R extends DoubleScalarInterface.RelWithAbs<AU, A, RU, R>> 79 extends DoubleScalarInterface<RU, R>, Scalar.RelWithAbs<AU, A, RU, R> 80 { 81 /** 82 * Construct a new Relative Immutable DoubleScalar of the right type. Each extending class must implement this method. 83 * @param value double; the double value 84 * @param unit U; the unit 85 * @return R a new relative instance of the DoubleScalar of the right type 86 */ 87 R instantiateRel(double value, RU unit); 88 89 /** 90 * Construct a new Absolute Immutable DoubleScalar of the right type. Each extending class must implement this method. 91 * @param value double; the double value 92 * @param unit AU; the absolute unit 93 * @return A a new absolute instance of the DoubleScalar of the right type 94 */ 95 A instantiateAbs(double value, AU unit); 96 } 97 98 /** 99 * Methods for Absolute Scalar. 100 * <p> 101 * Copyright (c) 2019-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. 102 * <br> 103 * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>. 104 * <p> 105 * @author <a href="https://www.tudelft.nl/averbraeck" target="_blank">Alexander Verbraeck</a> 106 * @param <AU> the absolute unit belonging to the absoluteunit 107 * @param <A> the absolute scalar belonging to the relative scalar 108 * @param <RU> the absolute unit belonging to the relative unit 109 * @param <R> the relative scalar belonging to the absolute scalar 110 */ 111 public interface Abs<AU extends AbsoluteLinearUnit<AU, RU>, A extends DoubleScalarInterface.Abs<AU, A, RU, R>, 112 RU extends Unit<RU>, R extends DoubleScalarInterface.RelWithAbs<AU, A, RU, R>> 113 extends DoubleScalarInterface<AU, A>, Scalar.Abs<AU, A, RU, R> 114 { 115 /** 116 * Construct a new Relative Immutable DoubleScalar of the right type. Each extending class must implement this method. 117 * @param value double; the double value 118 * @param unit U; the unit 119 * @return R a new relative instance of the DoubleScalar of the right type 120 */ 121 R instantiateRel(double value, RU unit); 122 123 /** 124 * Construct a new Absolute Immutable DoubleScalar of the right type. Each extending class must implement this method. 125 * @param value double; the double value 126 * @param unit AU; the absolute unit 127 * @return A a new absolute instance of the DoubleScalar of the right type 128 */ 129 A instantiateAbs(double value, AU unit); 130 } 131 132 }