-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathInterferometricMeasurement.cs
More file actions
30 lines (26 loc) · 1.01 KB
/
InterferometricMeasurement.cs
File metadata and controls
30 lines (26 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SL3Reader;
[StructLayout(LayoutKind.Sequential, Size = Size)]
internal readonly ref struct InterferometricMeasurement
{
public const int Size = 2 * sizeof(float);
public readonly float Delta;
public readonly float Depth;
public readonly bool IsValid
{
[SkipLocalsInit, MethodImpl(MethodImplOptions.AggressiveInlining)]
get => !double.IsNaN(Delta) && !double.IsNaN(Depth) && Delta is not < 0.001f and not > 1000.0f && Depth is not < 1f and not > 250.0f;
}
public readonly float MetricDistance
{
[SkipLocalsInit, MethodImpl(MethodImplOptions.AggressiveInlining)]
get => .3048f * float.Hypot(Delta, Depth);
}
public readonly float AngleInDegrees
{
[SkipLocalsInit, MethodImpl(MethodImplOptions.AggressiveInlining)]
get => 90 - 360 / float.Tau * float.Atan2(Depth, Delta);
}
public override readonly string ToString() => $"{Delta};{Depth}";
}