# The Transform Component

Manipulate the scale, rotation, and position of the entity.

## Overview

All of these methods and properties come from adoption of the `HasTransform` protocol.

## Topics

### Accessing the Component

`var transform: Transform`

The transform of the entity relative to its parent.

`struct Transform`

A component that defines the scale, rotation, and translation of an entity.

### Scaling an Entity

`var scale: SIMD3<Float>`

The scale of the entity relative to its parent.

`func scale(relativeTo: Entity?) -> SIMD3<Float>`

Gets the scale of an entity relative to the given entity.

`func setScale(SIMD3<Float>, relativeTo: Entity?)`

Sets the scale factor of the entity relative to the given reference entity.

### Rotating an Entity

`var orientation: simd_quatf`

The rotation of the entity relative to its parent.

`func orientation(relativeTo: Entity?) -> simd_quatf`

Gets the orientation of an entity relative to the given entity.

`func setOrientation(simd_quatf, relativeTo: Entity?)`

Sets the orientation of the entity relative to the given reference entity.

### Positioning an Entity

`var position: SIMD3<Float>`

The position of the entity relative to its parent.

`func position(relativeTo: Entity?) -> SIMD3<Float>`

Gets the position of an entity relative to the given entity.

`func setPosition(SIMD3<Float>, relativeTo: Entity?)`

Sets the position of the entity relative to the given reference entity.

### Using a Matrix

`func transformMatrix(relativeTo: Entity?) -> float4x4`

Gets the 4x4 transform matrix of an entity relative to the given entity.

`func setTransformMatrix(float4x4, relativeTo: Entity?)`

Sets the transform of the entity relative to the given reference entity using a 4x4 matrix representation.

### Moving an Entity

`func move(to: Transform, relativeTo: Entity?)`

Moves an entity instantly to a new location given by a transform.

`func move(to: float4x4, relativeTo: Entity?)`

Moves an entity instantly to a new location given by a 4x4 matrix.

`func look(at: SIMD3<Float>, from: SIMD3<Float>, upVector: SIMD3<Float>, relativeTo: Entity?)`

Positions and orients the entity towards a target from a given position.

### Converting Values Between Coordinate Spaces

`func convert(position: SIMD3<Float>, from: Entity?) -> SIMD3<Float>`

Converts a position from the local space of a reference entity to the local space of the entity on which you called this method.

`func convert(position: SIMD3<Float>, to: Entity?) -> SIMD3<Float>`

Converts a position from the local space of the entity on which you called this method to the local space of a reference entity.

`func convert(direction: SIMD3<Float>, from: Entity?) -> SIMD3<Float>`

Converts a direction vector from the local space of a reference entity to the local space of the entity on which you called this method.

`func convert(direction: SIMD3<Float>, to: Entity?) -> SIMD3<Float>`

Converts a direction vector from the local space of the entity on which you called this method to the local space of a reference entity.

`func convert(normal: SIMD3<Float>, from: Entity?) -> SIMD3<Float>`

Converts a normal vector from the local space of a reference entity to the local space of the entity on which you called this method.

`func convert(normal: SIMD3<Float>, to: Entity?) -> SIMD3<Float>`

Converts a normal vector from the local space of the entity on which you called this method to the local space of a reference entity.

`func convert(transform: Transform, from: Entity?) -> Transform`

Converts the scale, rotation, and position of a transform from the local space of a reference entity to the local space of the entity on which you called this method.

`func convert(transform: Transform, to: Entity?) -> Transform`

Converts the scale, rotation, and position of a transform from the local space of the entity on which you called this method to the local space of a reference entity.

### Getting a Bounding Box

`func visualBounds(recursive: Bool, relativeTo: Entity?, excludeInactive: Bool) -> BoundingBox`

Computes a bounding box for the entity in the specified space, optionally including child entities.

### Positioning Entities in Space

`protocol HasTransform`

An interface that enables manipulating the scale, rotation, and translation of an entity.