Click or drag to resize

PosAndRotExtensionsTransformPosAndRot Method

Transforms a pos&rot object from the local space to the world space. The opposite to InverseTransformPosAndRot(Transform, PosAndRot).

Namespace:  KSPDev.Extensions
Assembly:  KSPDev_Utils.1.2 (in KSPDev_Utils.1.2.dll) Version: 1.2 for KSP v1.6+
Syntax
C#
public static PosAndRot TransformPosAndRot(
	this Transform node,
	PosAndRot posAndRot
)
Request Example View Source

Parameters

node
Type: UnityEngineTransform
The node to use as a parent.
posAndRot
Type: KSPDev.TypesPosAndRot
The object in local space.

Return Value

Type: PosAndRot
A new pos&rot object in the wold space.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Transform. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Examples
public static void ToWorld() {
  var parent = new GameObject();
  parent.transform.position = Vector3.one;
  parent.transform.rotation = Quaternion.LookRotation(Vector3.up);
  var pr = new PosAndRot();
  Debug.LogFormat("Local: {0}", pr);
  Debug.LogFormat("World: {0}", parent.transform.TransformPosAndRot(pr));
}
See Also