## Libraries.Game.Collision.PhysicsPosition2D Documentation

This class stores coordinate systems in 2D space, where the coordinate system represent the position of the 2D item and the tilt of the 2D item with respect to your screen. NOTE: this class can be seen as the class that stores a 3x3 transformation matrix.

*Inherits from: *Libraries.Language.Object

## Summary

### Actions Summary Table

Actions | Description |
---|---|

Compare(Libraries.Language.Object object) | This action compares two object hash codes and returns an integer. |

Equals(Libraries.Language.Object object) | This action determines if two objects are equal based on their hash code values. |

GetAngle() | This action gets the tilt of the 2D object in radians. |

GetCosine() | This action gets the cosine of the tilt of the 2D object described by this PhysicsPosition2D. |

GetHashCode() | This action gets the hash code for an object. |

GetPosition() | This action gets the location of the 2D object (the 2D object's local origin) with respect to the global coordinates. |

GetSine() | This action gets the sine of the tilt of the 2D object. |

Multiply(Libraries.Game.Collision.PhysicsPosition2D transformA, Libraries.Game.Collision.PhysicsPosition2D transformB) | If the 2D object B's location is described from the point of view of the object "A," and this point of view is stored inside "PhysicsPosition2D transformB," and that the location of A is described from someone sitting at the global origin, and this point of view is stored inside "PhysicsPosition2D transformA," then this action finds out what would be the position and tilt of object B from someone that is sitting at the global origin. |

Multiply(Libraries.Game.Collision.PhysicsPosition2D transform, Libraries.Compute.Vector2 vector) | Given a point (Vector2 vector) relative to the local coordinates of a 2D object described by "PhysicsPosition2D transform," this action computes that point relative to the global coordinates. |

MultiplyAndTranslate(Libraries.Game.Collision.PhysicsPosition2D transform, Libraries.Compute.Vector2 vector) | Given a vector "Vector2 vector" that is in global coordinates, this action computes what "Vector2 vector" will be at relative to the object that has the positions at "PhysicsPosition2D transform. |

MultiplyAndTranslate(Libraries.Game.Collision.PhysicsPosition2D transformA, Libraries.Game.Collision.PhysicsPosition2D transformB) | This action computes what is the tilt and position of object B described by "PhysicsPosition2D transformB" relative to object A described by "PhysicsPosition2D transformA. |

MultiplyToOut(Libraries.Game.Collision.PhysicsPosition2D transform, Libraries.Compute.Vector2 vector, Libraries.Compute.Vector2 out) | Given a point (Vector2 vector) relative to the center of this item (PhysicsPosition2D transform), this action computes and returns that point in screen coordinates (Vector2 out). |

Set(Libraries.Compute.Vector2 position, number angle) | This action sets the physics position of the 2D object using the passed in position and sets the tilt of the 2D object using the angle passed in. |

Set(Libraries.Game.Collision.PhysicsPosition2D other) | This action sets the physics positions using another object of PhysicsPosition2D. |

SetCosine(number cosine) | This action sets the cosine of the tilt of the 2D object described by this PhysicsPosition2D. |

SetPosition(Libraries.Compute.Vector2 position) | This action sets the position of the 2D object (the 2D object's local origin with respect to the global coordinates). |

SetSine(number sine) | This action sets the sine of the tilt of the 2D object. |

SetToIdentity() | This action sets the tilt of the 2D object described by this PhysicsPosition2D to 0 and align the 2D object with the global origin. |

## Actions Documentation

### Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

**Example Code**

```
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
```

#### Parameters

- Libraries.Language.Object: The object to compare to.

#### Return

integer: The Compare result, Smaller, Equal, or Larger.

### Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

**Example Code**

```
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
```

#### Parameters

- Libraries.Language.Object: The to be compared.

#### Return

boolean: True if the hash codes are equal and false if they are not equal.

### GetAngle()

This action gets the tilt of the 2D object in radians.

#### Return

number: the tilt of the 2D object in radians.

### GetCosine()

This action gets the cosine of the tilt of the 2D object described by this PhysicsPosition2D. To learn more about cosine, you can visit the tutorial page by MathIsFun: https://www.mathsisfun.com/sine-cosine-tangent.html

#### Return

number: the cosine of the tilt of the 2D object.

### GetHashCode()

This action gets the hash code for an object.

**Example Code**

```
Object o
integer hash = o:GetHashCode()
```

#### Return

integer: The integer hash code of the object.

### GetPosition()

This action gets the location of the 2D object (the 2D object's local origin) with respect to the global coordinates.

#### Return

Libraries.Compute.Vector2: the current position of the 2D object.

### GetSine()

This action gets the sine of the tilt of the 2D object. To learn more about sine, you can visit the tutorial page by MathIsFun: https://www.mathsisfun.com/sine-cosine-tangent.html

#### Return

number: the sine of the tilt of the 2D object.

### Multiply(Libraries.Game.Collision.PhysicsPosition2D transformA, Libraries.Game.Collision.PhysicsPosition2D transformB)

If the 2D object B's location is described from the point of view of the object "A," and this point of view is stored inside "PhysicsPosition2D transformB," and that the location of A is described from someone sitting at the global origin, and this point of view is stored inside "PhysicsPosition2D transformA," then this action finds out what would be the position and tilt of object B from someone that is sitting at the global origin. In mathematical terms, this would be T_A * T_B, where T_A and T_B are both transformation matrices.

#### Parameters

- Libraries.Game.Collision.PhysicsPosition2D: The position of object A from the point of view of someone at the global origin.
- Libraries.Game.Collision.PhysicsPosition2D: The position of object B from the point of view of object A.

#### Return

Libraries.Game.Collision.PhysicsPosition2D: the position of object B from the point of view from someone at the global origin.

### Multiply(Libraries.Game.Collision.PhysicsPosition2D transform, Libraries.Compute.Vector2 vector)

Given a point (Vector2 vector) relative to the local coordinates of a 2D object described by "PhysicsPosition2D transform," this action computes that point relative to the global coordinates. The result is returned instead of changed within the function.

#### Parameters

- Libraries.Game.Collision.PhysicsPosition2D: The position and tilt of the 2D object.
- Libraries.Compute.Vector2: The point that is described from the point of view of the 2D object.

#### Return

Libraries.Compute.Vector2: the point described from the point of view of someone sitting on the origin of the glocal coordinates.

### MultiplyAndTranslate(Libraries.Game.Collision.PhysicsPosition2D transform, Libraries.Compute.Vector2 vector)

Given a vector "Vector2 vector" that is in global coordinates, this action computes what "Vector2 vector" will be at relative to the object that has the positions at "PhysicsPosition2D transform."

#### Parameters

- Libraries.Game.Collision.PhysicsPosition2D: The position and tilt of the 2D object.
- Libraries.Compute.Vector2: The point described from the point of view of someone sitting on the origin of the glocal coordinates.

#### Return

Libraries.Compute.Vector2: the point described from the point of view of the 2D object.

### MultiplyAndTranslate(Libraries.Game.Collision.PhysicsPosition2D transformA, Libraries.Game.Collision.PhysicsPosition2D transformB)

This action computes what is the tilt and position of object B described by "PhysicsPosition2D transformB" relative to object A described by "PhysicsPosition2D transformA." Currently, this action is not used in any other classes.

#### Parameters

- Libraries.Game.Collision.PhysicsPosition2D: The position of A relative to the global origin.
- Libraries.Game.Collision.PhysicsPosition2D: The position of B relative to the global origin.

#### Return

Libraries.Game.Collision.PhysicsPosition2D: the position of B relative to the position of A.

### MultiplyToOut(Libraries.Game.Collision.PhysicsPosition2D transform, Libraries.Compute.Vector2 vector, Libraries.Compute.Vector2 out)

Given a point (Vector2 vector) relative to the center of this item (PhysicsPosition2D transform), this action computes and returns that point in screen coordinates (Vector2 out). This action stores the result inside of "Vector2 out."

#### Parameters

- Libraries.Game.Collision.PhysicsPosition2D: The position and tilt of the 2D object.
- Libraries.Compute.Vector2: The point that is described from the point of view of the 2D object.
- Libraries.Compute.Vector2: The point described from the point of view of someone sitting on the origin of the glocal coordinates.

### Set(Libraries.Compute.Vector2 position, number angle)

This action sets the physics position of the 2D object using the passed in position and sets the tilt of the 2D object using the angle passed in.

#### Parameters

- Libraries.Compute.Vector2: The position of the 2D object to be stored.
- number angle: The tilt of the 2D object to be stored.

### Set(Libraries.Game.Collision.PhysicsPosition2D other)

This action sets the physics positions using another object of PhysicsPosition2D.

#### Parameters

- Libraries.Game.Collision.PhysicsPosition2D: The other PhysicsPosition2D that we will be copying from.

### SetCosine(number cosine)

This action sets the cosine of the tilt of the 2D object described by this PhysicsPosition2D. To learn more about sine, you can visit the tutorial page by MathIsFun: https://www.mathsisfun.com/sine-cosine-tangent.html

#### Parameters

- number cosine: The cosine of the tilt of the 2D object to be stored.

### SetPosition(Libraries.Compute.Vector2 position)

This action sets the position of the 2D object (the 2D object's local origin with respect to the global coordinates).

#### Parameters

- Libraries.Compute.Vector2: The position of the 2D object to be stored.

### SetSine(number sine)

This action sets the sine of the tilt of the 2D object. To learn more about sine, you can visit the tutorial page by MathIsFun: https://www.mathsisfun.com/sine-cosine-tangent.html

#### Parameters

### SetToIdentity()

This action sets the tilt of the 2D object described by this PhysicsPosition2D to 0 and align the 2D object with the global origin.