|
| 1 | +// Copyright © 2020 ONIXLabs |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +namespace OnixLabs.Core.Units; |
| 16 | + |
| 17 | +public readonly partial struct Temperature<T> |
| 18 | +{ |
| 19 | + /// <summary> |
| 20 | + /// Computes the sum of the specified <see cref="Temperature{T}"/> values. |
| 21 | + /// </summary> |
| 22 | + /// <param name="left">The left-hand value to add to.</param> |
| 23 | + /// <param name="right">The right-hand value to add.</param> |
| 24 | + /// <returns>Returns the sum of the specified <see cref="Temperature{T}"/> values.</returns> |
| 25 | + public static Temperature<T> Add(Temperature<T> left, Temperature<T> right) |
| 26 | + { |
| 27 | + return new Temperature<T>(left.Kelvin + right.Kelvin); |
| 28 | + } |
| 29 | + |
| 30 | + /// <summary> |
| 31 | + /// Computes the difference between the specified <see cref="Temperature{T}"/> values. |
| 32 | + /// </summary> |
| 33 | + /// <param name="left">The left-hand value to subtract from.</param> |
| 34 | + /// <param name="right">The right-hand value to subtract.</param> |
| 35 | + /// <returns>Returns the difference between the specified <see cref="Temperature{T}"/> values.</returns> |
| 36 | + public static Temperature<T> Subtract(Temperature<T> left, Temperature<T> right) |
| 37 | + { |
| 38 | + return new Temperature<T>(left.Kelvin - right.Kelvin); |
| 39 | + } |
| 40 | + |
| 41 | + /// <summary> |
| 42 | + /// Computes the product of the specified <see cref="Temperature{T}"/> values. |
| 43 | + /// </summary> |
| 44 | + /// <param name="left">The left-hand value to multiply.</param> |
| 45 | + /// <param name="right">The right-hand value to multiply by.</param> |
| 46 | + /// <returns>Returns the product of the specified <see cref="Temperature{T}"/> values.</returns> |
| 47 | + public static Temperature<T> Multiply(Temperature<T> left, Temperature<T> right) |
| 48 | + { |
| 49 | + return new Temperature<T>(left.Kelvin * right.Kelvin); |
| 50 | + } |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// Computes the quotient of the specified <see cref="Temperature{T}"/> values. |
| 54 | + /// </summary> |
| 55 | + /// <param name="left">The left-hand value to divide.</param> |
| 56 | + /// <param name="right">The right-hand value to divide by.</param> |
| 57 | + /// <returns>Returns the quotient of the specified <see cref="Temperature{T}"/> values.</returns> |
| 58 | + public static Temperature<T> Divide(Temperature<T> left, Temperature<T> right) |
| 59 | + { |
| 60 | + return new Temperature<T>(left.Kelvin / right.Kelvin); |
| 61 | + } |
| 62 | + |
| 63 | + /// <summary> |
| 64 | + /// Computes the sum of the specified <see cref="Temperature{T}"/> values. |
| 65 | + /// </summary> |
| 66 | + /// <param name="left">The left-hand value to add to.</param> |
| 67 | + /// <param name="right">The right-hand value to add.</param> |
| 68 | + /// <returns>Returns the sum of the specified <see cref="Temperature{T}"/> values.</returns> |
| 69 | + public static Temperature<T> operator +(Temperature<T> left, Temperature<T> right) |
| 70 | + { |
| 71 | + return Add(left, right); |
| 72 | + } |
| 73 | + |
| 74 | + /// <summary> |
| 75 | + /// Computes the difference between the specified <see cref="Temperature{T}"/> values. |
| 76 | + /// </summary> |
| 77 | + /// <param name="left">The left-hand value to subtract from.</param> |
| 78 | + /// <param name="right">The right-hand value to subtract.</param> |
| 79 | + /// <returns>Returns the difference between the specified <see cref="Temperature{T}"/> values.</returns> |
| 80 | + public static Temperature<T> operator -(Temperature<T> left, Temperature<T> right) |
| 81 | + { |
| 82 | + return Subtract(left, right); |
| 83 | + } |
| 84 | + |
| 85 | + /// <summary> |
| 86 | + /// Computes the product of the specified <see cref="Temperature{T}"/> values. |
| 87 | + /// </summary> |
| 88 | + /// <param name="left">The left-hand value to multiply.</param> |
| 89 | + /// <param name="right">The right-hand value to multiply by.</param> |
| 90 | + /// <returns>Returns the product of the specified <see cref="Temperature{T}"/> values.</returns> |
| 91 | + public static Temperature<T> operator *(Temperature<T> left, Temperature<T> right) |
| 92 | + { |
| 93 | + return Multiply(left, right); |
| 94 | + } |
| 95 | + |
| 96 | + /// <summary> |
| 97 | + /// Computes the quotient of the specified <see cref="Temperature{T}"/> values. |
| 98 | + /// </summary> |
| 99 | + /// <param name="left">The left-hand value to divide.</param> |
| 100 | + /// <param name="right">The right-hand value to divide by.</param> |
| 101 | + /// <returns>Returns the quotient of the specified <see cref="Temperature{T}"/> values.</returns> |
| 102 | + public static Temperature<T> operator /(Temperature<T> left, Temperature<T> right) |
| 103 | + { |
| 104 | + return Divide(left, right); |
| 105 | + } |
| 106 | +} |
0 commit comments