Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
OutPose.cs
Go to the documentation of this file.
1 using UnityEngine;
2 
3 namespace droid.Runtime.Utilities.Structs {
4  public class OutPose {
8  protected static readonly Matrix4x4 _FlipZ = Matrix4x4.Scale(new Vector3(1, 1, -1));
9 
11  public Vector3 Position { get; protected set; }
12 
14  public Quaternion Orientation { get; protected set; }
15 
17  public Matrix4x4 Matrix { get; protected set; }
18 
20  public Matrix4x4 RightHandedMatrix { get { return _FlipZ * this.Matrix * _FlipZ; } }
21 
24  public OutPose() {
25  this.Position = Vector3.zero;
26  this.Orientation = Quaternion.identity;
27  this.Matrix = Matrix4x4.identity;
28  }
29 
31  public OutPose(Vector3 position, Quaternion orientation) { this.Set(position, orientation); }
32 
34  public OutPose(Matrix4x4 matrix) { this.Set(matrix); }
35 
36  protected void Set(Vector3 position, Quaternion orientation) {
37  this.Position = position;
38  this.Orientation = orientation;
39  this.Matrix = Matrix4x4.TRS(position, orientation, Vector3.one);
40  }
41 
42  protected void Set(Matrix4x4 matrix) {
43  this.Matrix = matrix;
44  this.Position = matrix.GetColumn(3);
45  this.Orientation = Quaternion.LookRotation(matrix.GetColumn(2), matrix.GetColumn(1));
46  }
47  }
48 
49  public class MutableOutPose : OutPose {
51  public new void Set(Vector3 position, Quaternion orientation) { base.Set(position, orientation); }
52 
54  public new void Set(Matrix4x4 matrix) { base.Set(matrix); }
55 
57  public void SetRightHanded(Matrix4x4 matrix) { this.Set(_FlipZ * matrix * _FlipZ); }
58  }
59 }
void Set(Vector3 position, Quaternion orientation)
Definition: OutPose.cs:36
OutPose(Matrix4x4 matrix)
Constructor that takes a Matrix4x4.
Definition: OutPose.cs:34
new void Set(Vector3 position, Quaternion orientation)
Sets the position and orientation from a Vector3 + Quaternion.
Definition: OutPose.cs:51
OutPose(Vector3 position, Quaternion orientation)
Constructor that takes a Vector3 and a Quaternion.
Definition: OutPose.cs:31
new void Set(Matrix4x4 matrix)
Sets the position and orientation from a Matrix4x4.
Definition: OutPose.cs:54
void SetRightHanded(Matrix4x4 matrix)
Sets the position and orientation from a right-handed Matrix4x4.
Definition: OutPose.cs:57
void Set(Matrix4x4 matrix)
Definition: OutPose.cs:42