Newer
Older
lacoche
committed
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using UnityEngine;
public class WorldAnalysisUnityHelper
{
/// <summary>
/// Convert a float array of length 3 to a Vector3
/// </summary>
/// <param name="value">the values to convert</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public static Vector3 ConvertETSIVector3ToUnity(ETSI.ARF.OpenAPI.WorldAnalysis.Vector3 value)
{
if (value.Count == 3) return new Vector3(value[0], value[1], value[2]);
throw new ArgumentException("The numer of floats in the value parameter must be 3!");
}
/// <summary>
/// Convert a float array of length 4 to a Quaternion
/// </summary>
/// <param name="value">the values to convert</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public static Quaternion ConvertETSIARFQuaternionToUnity(ETSI.ARF.OpenAPI.WorldAnalysis.Quaternion value)
{
if (value.Count == 4) return new Quaternion(value[0], value[1], value[2], value[3]);
throw new ArgumentException("The numer of floats in the value parameter must be 4!");
}
/// <summary>
/// Convert a float array of length 16 to a Matrix
/// </summary>
/// <param name="matrix"></param>
/// <returns></returns>
public static Matrix4x4 ConvertETSIARFTransform3DToUnity(ETSI.ARF.OpenAPI.WorldAnalysis.Transform3D value)
{
if (value.Count == 16)
{
Matrix4x4 resul = new Matrix4x4();
resul[0, 0] = value[0];
resul[0, 1] = value[1];
resul[0, 2] = value[2];
resul[0, 3] = value[3];
resul[1, 0] = value[4];
resul[1, 1] = value[5];
resul[1, 2] = value[6];
resul[1, 3] = value[7];
resul[2, 0] = value[8];
resul[2, 1] = value[9];
resul[2, 2] = value[10];
resul[2, 3] = value[11];
resul[3, 0] = value[12];
resul[3, 1] = value[13];
resul[3, 2] = value[14];
resul[3, 3] = value[15];
return resul;
}
else
{
throw new ArgumentException("The numer of floats in the value parameter must be 16!");
}
}
}