Represents a measurable quantity defined by a numerical value and a physical unit. The type parameter D specifies the dimension of the quantity.
This case class is useful for performing unit-aware numerical operations and rendering quantities in a human-readable format.
Value parameters
- unit
-
the physical unit associated with the quantity, specified as a
PhysicalUnit[D] - value
-
the numerical value of the quantity, which is represented as a
Valuable
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Renderableclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Multiplies this quantity with another quantity, resulting in a new quantity whose dimension is the product of the dimensions of the two quantities.
Multiplies this quantity with another quantity, resulting in a new quantity whose dimension is the product of the dimensions of the two quantities.
Value parameters
- other
-
the quantity to multiply with this quantity. The dimension of the other quantity must be of type
D2, a subtype ofDimension.
Attributes
- Returns
-
a new quantity representing the product of this quantity and the other quantity. The resulting quantity has a dimension defined as
MulDim[D, D2].
Adds this quantity to another quantity of the same dimension. If the units of both quantities are compatible, the resulting quantity is computed by converting the other quantity into the same unit as this quantity (if necessary) and summing their values.
Adds this quantity to another quantity of the same dimension. If the units of both quantities are compatible, the resulting quantity is computed by converting the other quantity into the same unit as this quantity (if necessary) and summing their values.
Value parameters
- other
-
the quantity to be added, which must have the same dimension as this quantity.
Attributes
- Returns
-
an
Optioncontaining the resulting quantity if the units are compatible, orNoneif the units are incompatible.
Divides this quantity by another quantity, resulting in a new quantity whose dimension is the quotient of the dimensions of the two quantities.
Divides this quantity by another quantity, resulting in a new quantity whose dimension is the quotient of the dimensions of the two quantities.
Value parameters
- other
-
the quantity to divide by. The dimension of the other quantity must be of type
D2, a subtype ofDimension.
Attributes
- Returns
-
a new quantity representing the quotient of this quantity and the other quantity. The resulting quantity has a dimension defined as
DivDim[D, D2].
Converts this Quantity to an equivalent Quantity that has a different unit and returns the result as an Option of the converted quantity. The conversion is based on the scale factors of the source and target units relative to the Standard International (SI) base units. If the conversion is successful, a new Quantity instance is created with the converted value and target unit.
Converts this Quantity to an equivalent Quantity that has a different unit and returns the result as an Option of the converted quantity. The conversion is based on the scale factors of the source and target units relative to the Standard International (SI) base units. If the conversion is successful, a new Quantity instance is created with the converted value and target unit.
Value parameters
- targetUnit
-
the physical unit to which this quantity should be converted. The dimension of the target unit must correspond to the dimension of this quantity.
Attributes
- Returns
-
an
Optioncontaining the convertedQuantityif the operation is valid, orNoneif the conversion cannot be performed due to the absence of a valid numerical value.
Inherited methods
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
Concrete fields
Computes the multiplicative inverse of this quantity, resulting in a quantity that represents one divided by the value of this quantity.
Computes the multiplicative inverse of this quantity, resulting in a quantity that represents one divided by the value of this quantity.
Attributes
- Returns
-
an
Optioncontaining the inverted quantity if the operation is valid, orNoneif the operation cannot be performed.
Renders the quantity as a string representation by combining the rendered value and the unit's symbol.
Renders the quantity as a string representation by combining the rendered value and the unit's symbol.
Attributes
- Returns
-
a string consisting of the value's rendered representation followed by the unit's symbol, separated by a space
Convenience method for LaTeX rendering. Delegates to toLatex function in companion object.
Convenience method for LaTeX rendering. Delegates to toLatex function in companion object.
Attributes
Computes the squared value of the quantity by multiplying it with itself.
Computes the squared value of the quantity by multiplying it with itself.
Attributes
- Returns
-
an
Optioncontaining the squared quantity if the operation is valid, orNoneif the operation cannot be performed.