Struct Interval
Represents an range between two numbers.
Namespace: Paramdigma.Core.Collections
Assembly: Paramdigma.Core.dll
Syntax
public struct Interval
Constructors
| Improve this Doc View SourceInterval(Interval)
Initializes a new instance of the Interval struct from another interval.
Declaration
public Interval(Interval interval)
Parameters
Type | Name | Description |
---|---|---|
Interval | interval | Interval to duplicate. |
Interval(Double, Double)
Initializes a new instance of the Interval struct from a start and end value.
Declaration
public Interval(double start, double end)
Parameters
Type | Name | Description |
---|---|---|
System.Double | start | Starting value of the interval. |
System.Double | end | Ending value of the interval. |
Properties
| Improve this Doc View SourceEnd
Gets or sets the ending value of the interval.
Declaration
public double End { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Value will always be the biggest unless interval is inverted. |
HasInvertedDirection
Gets a value indicating whether an interval has it's direciton inverted (Start > End).
Declaration
public bool HasInvertedDirection { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Length
Gets the space between the start and end of the interval.
Declaration
public double Length { get; }
Property Value
Type | Description |
---|---|
System.Double |
Start
Gets or sets the starting value of the interval.
Declaration
public double Start { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Value will always be lower unless interval is inverted. |
Unit
Gets a new unit interval.
Declaration
public static Interval Unit { get; }
Property Value
Type | Description |
---|---|
Interval | New interval from 0.0 to 1.0. |
Methods
| Improve this Doc View SourceContains(Double)
Check if a number is contained inside this interval.
Declaration
public bool Contains(double number)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | Number to check containment. |
Returns
Type | Description |
---|---|
System.Boolean | True if number is contained. |
Crop(Double)
Crop a number so that it is contained inside this interval.
Declaration
public double Crop(double number)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | Number to crop. |
Returns
Type | Description |
---|---|
System.Double | Cropped number. |
CropNumber(Double, Interval)
Crop a number so that it's contained on the given interval.
Declaration
public static double CropNumber(double number, Interval interval)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | Number to crop. |
Interval | interval | Interval to crop number with. |
Returns
Type | Description |
---|---|
System.Double | Cropped number value. |
FlipDirection()
Swap the Start and End values of this interval.
Declaration
public void FlipDirection()
Remap(Double, Interval)
Remap a number from this interval to a given one.
Declaration
public double Remap(double number, Interval toInterval)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | Number to remap. |
Interval | toInterval | Interval to remap number to. |
Returns
Type | Description |
---|---|
System.Double | Remapped number inside given interval. |
RemapFromUnit(Double)
Remap a number from a unit interval to this interval.
Declaration
public double RemapFromUnit(double number)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | Number to remap. |
Returns
Type | Description |
---|---|
System.Double | Remapped number. |
RemapNumber(Double, Interval, Interval)
Remap a number from one interval to another.
Declaration
public static double RemapNumber(double number, Interval fromInterval, Interval toInterval)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | Number to remap. |
Interval | fromInterval | Origin interval. |
Interval | toInterval | Destination interval. |
Returns
Type | Description |
---|---|
System.Double | Remapped number. |
RemapToUnit(Double)
Remap a number from this interval to a unit interval.
Declaration
public double RemapToUnit(double number)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | Number to remap. |
Returns
Type | Description |
---|---|
System.Double | Value remaped from 0 to 1. |