AlignLocalToWorldPose
(
localToWorld
, local
, world
)
|
This is an old utility method, new uses of which should be avoided.
For homogeneous transform arithmetic, just use Unity's built-in Transform and matrix math support.
The naming and use of Pose representation in this implementation can be confusing, so this explanation will avoid them and map back at the end. Conceptually, there are three things: a scaled transform T in world space, an unscaled transform A in T space, and an unscaled transform B in world space. The goal is to find a scaled transform T' (sharing the scale of T) such that an unmodified A in T' equals B when mapped to world space; colloquially, "find where we need to move T to so that A and B are on top of one another." Mathematically, this means the relationship between T' and B is the same as the relationship between T and A; thus, if we find T in the space of A (or, more precisely, A as a scaled transform in world space), we can use that same relationship with B to find T'. This gives us the following arithmetic (treating each transform as a "local to world" matrix): given T, A, and B
A_inWorldSpace := T * A
T_inASpace := inverse(A_inWorldSpace) * T
T' := b * T_inASpace
Mapping this back to the variables and assumptions of this implementation, localToWorld is T, local is A, and world is B. The fact that the result T' is a scaled transform is not reflected in the return value of this extension and is instead implicit in its usage. The position and rotation of the returned Pose must be assigned directly to the corresponding fields of the Transform which provided localToWorld, without modifying the scale of that Transform; any other usage may not yield the desired alignment.
Signature
static Pose Oculus.Interaction.TransformerUtils.AlignLocalToWorldPose(Matrix4x4 localToWorld, Pose local, Pose world) Parameters localToWorld: Matrix4x4Â
T (see remarks for details).
local: PoseÂ
A (see remarks for details).
world: PoseÂ
B (see remarks for details).
Returns PoseÂ
T', excluding scale (see remarks for details).
|
ConstrainAlongDirection
(
position
, origin
, direction
, min
, max
)
|
Constrains a position to a certain range of positions along a line defined by position and direction minimally distant from a range of points from origin plus direction scaled by min to origin plus direction scaled by max .
This is an extremely specialized utility used only by TwoGrabPlaneTransformer.
Signature
static Vector3 Oculus.Interaction.TransformerUtils.ConstrainAlongDirection(Vector3 position, Vector3 origin, Vector3 direction, FloatConstraint min, FloatConstraint max) Parameters position: Vector3Â
The position to be constrained.
origin: Vector3Â
The origin of the line to which position should be projected for constraint.
direction: Vector3Â
The direction along which position should be constrained.
min: FloatConstraintÂ
The minimum signed distance along the line defined by origin and direction to which the closest projection of position should be constrained.
max: FloatConstraintÂ
The maximum signed distance along the line defined by origin and direction to which the closest projection of position should be constrained.
Returns Vector3Â
The constrained position.
|
GenerateParentConstraints
(
constraints
, initialPosition
)
|
Generates a new set of PositionConstraints based on an initialPosition .
Signature
static PositionConstraints Oculus.Interaction.TransformerUtils.GenerateParentConstraints(PositionConstraints constraints, Vector3 initialPosition) Parameters constraints: PositionConstraintsÂ
The PositionConstraints upon which the new constraints should be based.
initialPosition: Vector3Â
The initial position from which relative constraints should be relative.
Returns PositionConstraintsÂ
New constraints which take initialPosition into account.
|
GenerateParentConstraints
(
constraints
, initialScale
)
|
Generates a new set of ScaleConstraints based on an initialScale .
Signature
static ScaleConstraints Oculus.Interaction.TransformerUtils.GenerateParentConstraints(ScaleConstraints constraints, Vector3 initialScale) Parameters initialScale: Vector3Â
The initial scale from which relative constraints should be relative.
Returns ScaleConstraintsÂ
New constraints which take initialScale into account.
|
GetConstrainedTransformPosition
(
unconstrainedPosition
, positionConstraints
, relativeTransform
)
|
Applies a set of PositionConstraints to a vector representing the position of a Transform.
Signature
static Vector3 Oculus.Interaction.TransformerUtils.GetConstrainedTransformPosition(Vector3 unconstrainedPosition, PositionConstraints positionConstraints, Transform relativeTransform=null) Parameters unconstrainedPosition: Vector3Â
The position of the Transform before constraining.
positionConstraints: PositionConstraintsÂ
The constraints to be applied to positionConstraints .
relativeTransform: TransformÂ
The transform to which constraint should be considered relative; if omitted, constraining will be applied relative to world space.
Returns Vector3Â
A position which is as similar as possible to unconstrainedPosition but allowed by positionConstraints .
|
GetConstrainedTransformRotation
(
unconstrainedRotation
, rotationConstraints
, relativeTransform
)
|
Applies a set of RotationConstraints to a Quaternion representing the rotation of a Transform.
Signature
static Quaternion Oculus.Interaction.TransformerUtils.GetConstrainedTransformRotation(Quaternion unconstrainedRotation, RotationConstraints rotationConstraints, Transform relativeTransform=null) Parameters unconstrainedRotation: QuaternionÂ
The rotation of the Transform before constraining.
rotationConstraints: RotationConstraintsÂ
The constraints to be applied to unconstrainedRotation .
relativeTransform: TransformÂ
The transform to which constraint should be considered relative; if omitted, constraining will be applied relative to world space.
Returns QuaternionÂ
A rotation which is as similar as possible to unconstrainedRotation but allowed by rotationConstraints .
|
GetConstrainedTransformScale
(
unconstrainedScale
, scaleConstraints
)
|
Applies a set of ScaleConstraints to a vector representing the scale of a Transform.
Signature
static Vector3 Oculus.Interaction.TransformerUtils.GetConstrainedTransformScale(Vector3 unconstrainedScale, ScaleConstraints scaleConstraints) Parameters unconstrainedScale: Vector3Â
The scale of the Transform before constraining.
scaleConstraints: ScaleConstraintsÂ
The constraints to be applied to unconstrainedScale .
Returns Vector3Â
A scale which is as similar as possible to unconstrainedScale but allowed by scaleConstraints .
|
LocalToWorldMagnitude
(
magnitude
, localToWorld
)
|
Calculates how large a certain magnitude in local space is in world space.
This method specifically works by approximating the scale change from the local-space Z axis. If the transform hierarchy involves skew (rotated nonuniform scales), the result may not fully describe the scale relationship between local and world space. For more information, refer to Unity's documentation for Transform.lossyScale.
Signature
static float Oculus.Interaction.TransformerUtils.LocalToWorldMagnitude(float magnitude, Matrix4x4 localToWorld) Parameters magnitude: floatÂ
The magnitude to be converted to world space.
localToWorld: Matrix4x4Â
The homogeneous transform from local to world space.
Returns floatÂ
The magnitude in world space.
|
WorldToLocalMagnitude
(
magnitude
, worldToLocal
)
|
Calculates how large a certain magnitude in world space is in local space.
This method specifically works by approximating the scale change from the world-space Z axis. If the transform hierarchy involves skew (rotated nonuniform scales), the result may not fully describe the scale relationship between local and world space. For more information, refer to Unity's documentation for Transform.lossyScale.
Signature
static float Oculus.Interaction.TransformerUtils.WorldToLocalMagnitude(float magnitude, Matrix4x4 worldToLocal) Parameters magnitude: floatÂ
The magnitude to be converted to local space.
worldToLocal: Matrix4x4Returns floatÂ
The magnitude in local space.
|
WorldToLocalPose
(
worldPose
, worldToLocal
)
|
Convenience method for taking a Pose in world space (or whatever space is the domain of the transform represented by worldToLocal ) and returning its representation in local space (or whatever space is the range of worldToLocal ).
Signature
static Pose Oculus.Interaction.TransformerUtils.WorldToLocalPose(Pose worldPose, Matrix4x4 worldToLocal) Parameters worldPose: PoseÂ
The Pose to be transformed.
worldToLocal: Matrix4x4Â
The transformation to be applied.
Returns PoseÂ
The image of worldPose in worldToLocal 's range.
|
ConstraintsAreRelative
: bool |
Indicates whether the constraints should be considered relative (i.e., applying to a Transform's local position relative to its parent Transform) or absolute (i.e., applying to a Transform's position in world space).
Signature
bool Oculus.Interaction.TransformerUtils.PositionConstraints.ConstraintsAreRelative |
XAxis
: ConstrainedAxis |
Signature
ConstrainedAxis Oculus.Interaction.TransformerUtils.PositionConstraints.XAxis |
YAxis
: ConstrainedAxis |
Signature
ConstrainedAxis Oculus.Interaction.TransformerUtils.PositionConstraints.YAxis |
ZAxis
: ConstrainedAxis |
Signature
ConstrainedAxis Oculus.Interaction.TransformerUtils.PositionConstraints.ZAxis |
XAxis
: ConstrainedAxis |
Signature
ConstrainedAxis Oculus.Interaction.TransformerUtils.RotationConstraints.XAxis |
YAxis
: ConstrainedAxis |
Signature
ConstrainedAxis Oculus.Interaction.TransformerUtils.RotationConstraints.YAxis |
ZAxis
: ConstrainedAxis |
Signature
ConstrainedAxis Oculus.Interaction.TransformerUtils.RotationConstraints.ZAxis |
ConstraintsAreRelative
: bool |
Indicates whether the constraints should be considered relative (i.e., applying to a Transform's local scale relative to its parent Transform) or absolute (i.e., applying to a Transform's scale relative to world space).
Signature
bool Oculus.Interaction.TransformerUtils.ScaleConstraints.ConstraintsAreRelative |
XAxis
: ConstrainedAxis |
Signature
ConstrainedAxis Oculus.Interaction.TransformerUtils.ScaleConstraints.XAxis |
YAxis
: ConstrainedAxis |
Signature
ConstrainedAxis Oculus.Interaction.TransformerUtils.ScaleConstraints.YAxis |
ZAxis
: ConstrainedAxis |
Signature
ConstrainedAxis Oculus.Interaction.TransformerUtils.ScaleConstraints.ZAxis |
AxisRange
: FloatRange |
Indicates the FloatRange of permissible values for the datum to which this ConstrainedAxis pertains.
Signature
FloatRange Oculus.Interaction.TransformerUtils.ConstrainedAxis.AxisRange |
ConstrainAxis
: bool |
Indicates whether the constraints described in this ConstrainedAxis should be applied.
If false, the datum to which this ConstrainedAxis pertains should be left unconstrained by this instance.
Signature
bool Oculus.Interaction.TransformerUtils.ConstrainedAxis.ConstrainAxis |
Unconstrained
: ConstrainedAxis |
A default ConstrainedAxis instance which applies no constraints.
Signature
ConstrainedAxis Oculus.Interaction.TransformerUtils.ConstrainedAxis.Unconstrained |
Max
: float |
Signature
float Oculus.Interaction.TransformerUtils.FloatRange.Max |
Min
: float |
Signature
float Oculus.Interaction.TransformerUtils.FloatRange.Min |