Skip to content

Commit 3ee2911

Browse files
committed
added ros <--> unity conversion extension
1 parent 29de92e commit 3ee2911

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using UnityEngine;
2+
3+
namespace ZO.Util.Extensions {
4+
public static class ZOROSConversionExtensions {
5+
public static Vector3 Ros2Unity(this Vector3 v) {
6+
return new Vector3(-v.y, v.z, v.x);
7+
}
8+
9+
public static Vector3 Unity2Ros(this Vector3 v) {
10+
return new Vector3(v.z, -v.x, v.y);
11+
}
12+
13+
public static Vector3 Ros2UnityScale(this Vector3 v) {
14+
return new Vector3(v.y, v.z, v.x);
15+
}
16+
17+
public static Vector3 Unity2RosScale(this Vector3 v) {
18+
return new Vector3(v.z, v.x, v.y);
19+
}
20+
21+
public static Quaternion Ros2Unity(this Quaternion q) {
22+
return new Quaternion(q.y, -q.z, -q.x, q.w);
23+
}
24+
25+
public static Quaternion Unity2Ros(this Quaternion q) {
26+
return new Quaternion(-q.z, q.x, -q.y, q.w);
27+
}
28+
29+
}
30+
31+
}

Runtime/Scripts/Util/Extensions/ZOROSConversionExtensions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)