Api Transform
struct

Transform

public sealed struct Transform

A struct containing a position, rotation and scale. This is commonly used in engine to describe entity position, bone position and scene object position.

Constructors

Transform(Vector3 pos)
Transform()
Transform(Vector3 position, Rotation rotation, Single scale)
Transform(Vector3 position, Rotation rotation, Vector3 scale)

Properties

Name Type Description
UniformScale Single A uniform scale component. Generally the scale is uniform, and we'll just access the .x component.
Forward Vector3
Backward Vector3
Up Vector3
Down Vector3
Right Vector3
Left Vector3
IsValid Boolean Returns true if position, scale and rotation are valid
ForwardRay Ray Return a ray from this transform, which goes from the center along the Forward

Methods

Vector3 PointToLocal(Vector3 worldPoint)

Convert a point in world space to a point in this transform's local space

Vector3 NormalToLocal(Vector3 worldNormal)

Convert a world normal to a local normal

Rotation RotationToLocal(Rotation worldRot)

Convert a world rotation to a local rotation

Vector3 PointToWorld(Vector3 localPoint)

Convert a point in this transform's local space to a point in world space

Vector3 NormalToWorld(Vector3 localNormal)

Convert a local normal to a world normal

Rotation RotationToWorld(Rotation localRotation)

Convert a local rotation to a world rotation

Transform ToLocal(Transform child)

Convert child transform from the world to a local transform

Transform ToWorld(Transform child)

Convert child transform from local to the world

static Transform Lerp(Transform a, Transform b, Single t, Boolean clamp)

Perform linear interpolation from one transform to another.

Transform LerpTo(Transform target, Single t, Boolean clamp = True)

Linearly interpolate from this transform to given transform.

Transform Add(Vector3 position, Boolean worldSpace)

Add a position to this transform and return the result.

Transform WithPosition(Vector3 position)

Return this transform with a new position.

Transform WithPosition(Vector3 position, Rotation rotation)

Return this transform with a new position and rotation

Transform WithRotation(Rotation rotation)

Return this transform with a new rotation.

Transform WithScale(Single scale)

Return this transform with a new scale.

Transform WithScale(Vector3 scale)

Return this transform with a new scale.

Transform Mirror(Plane plane)

Create a transform that is the mirror of this

Transform RotateAround(Vector3 center, Rotation rot)

Rotate this transform around given point by given rotation and return the result.

center — Point to rotate around.
rot — How much to rotate by. Single) can be useful.
returns — The rotated transform.
static Transform Concat(Transform parent, Transform local)

Concatenate (add together) the 2 given transforms and return a new resulting transform.

static Transform Parse(String str)

Given a string, try to convert this into a transform. The format is "px,py,pz,rx,ry,rz,rw".

Boolean AlmostEqual(Transform tx, Single delta = 0.0001)

Returns true if we're nearly equal to the passed transform.

tx — The value to compare with
delta — The max difference between component values
returns — True if nearly equal

Fields

Name Type Description
Zero static Transform Represents a zero transform, that being, a transform with scale of 1, position of Zero and rotation of Identity.
Position Vector3 Position of the transform.
Scale Vector3 Scale of the transform. Does not itself scale Position or Rotation.
Rotation Rotation Rotation of this transform.
Assembly: Sandbox.System Full Name: Transform