TRS Struct Reference

TRS comes from scenegraph terminology and is used to store a Translate/Rotate/Scale 2d transform in a canonical way. More...

List of all members.

Classes

class  Local
 Some aliases for commonly used points that can be passed to Centering. More...

Public Member Functions

void Rotate (float angle)
 Rotate the object by an angle.
void Rotate (Vector2 rotation)
 Rotate the object by an angle.
 TRS (Bounds2 a_bounds)
 Convert from Bounds2: a_bounds.Min becomes T and a_bounds.Size becomes S (no rotation).
Bounds2 Bounds2 ()
 Convert to Bounds2.
void Centering (Vector2 normalized_pos)
 Translate the TRS so that the normalized point given in input becomes (0,0).
override string ToString ()

Static Public Member Functions

static TRS Tile (Vector2i num_tiles, Vector2i tile_index, TRS source_area)
 Get a subregion from source_area, given a number of tiles and a tile index, assuming evenly spaced subdivision.

Public Attributes

Vector2 T
 Translation.
Vector2 R
 Rotation - stored as a unit vector (cos,sin).
Vector2 S
 Scale (or Size).

Static Public Attributes

static TRS Quad0_1
 A TRS that covers the unit quad that goes from (0,0) to (1,1).
static TRS QuadMinus1_1
 A TRS that covers the quad that goes from (-1,-1) to (1,1).

Properties

Vector2 X [get]
 The support X vector, which goes from bottom left to bottom right.
Vector2 Y [get]
 The support Y vector, which goes from bottom left to top left.
Vector2 Point00 [get]
 The bottom left point (the base point), (0,0) in 'local' coordinates.
Vector2 Point10 [get]
 The bottom right point, (1,0) in 'local' coordinates.
Vector2 Point01 [get]
 The top left point, (0,1) in 'local' coordinates.
Vector2 Point11 [get]
 The top right point, (1,1) in 'local' coordinates.
Vector2 Center [get]
 Return the center of the oriented box defined by this TRS.
Vector2 RotationNormalize [get, set]
 RotationNormalize is like Rotation, but it normalizes on set, to prevent the unit vector from drifting because of accumulated numerical imprecision.
float Angle [get, set]
 This property lets you set/get rotation as a angle.

Detailed Description

TRS comes from scenegraph terminology and is used to store a Translate/Rotate/Scale 2d transform in a canonical way.

It also defines an oriented bounding box. We use it for storing both sprite positionning/size and sprite UV.


Member Function Documentation

Convert to Bounds2.

Note that end points won't match if there is a Rotation, but in all cases the returned bounds fully contains the TRS.

void Centering ( Vector2  normalized_pos)

Translate the TRS so that the normalized point given in input becomes (0,0).

There are a few predefined normalized points in TRS.Local.

Parameters:
normalized_posThe normalized position that will become the new center. For example (0.5,0.5) represents the center of the TRS, regardless of the actual size, position and orientation of the TRS. (0,0) is the bottom left point, (1,1) is the top right point etc.
void Rotate ( Vector2  rotation)

Rotate the object by an angle.

Parameters:
rotationThe (cos(angle),sin(angle)) unit vector representing the rotation.

This lets you precompute the cos,sin needed during rotation.

void Rotate ( float  angle)

Rotate the object by an angle.

Parameters:
angleRotation angle in radian.
static TRS Tile ( Vector2i  num_tiles,
Vector2i  tile_index,
TRS  source_area 
) [static]

Get a subregion from source_area, given a number of tiles and a tile index, assuming evenly spaced subdivision.

Typically source_area will be Quad0_1 (the unit quad, means the whole texture) and we return the uv info for a given tile in the tiled texture.

override string ToString ( )

Property Documentation

float Angle [get, set]

This property lets you set/get rotation as a angle.

This is expensive and brings the usual angle discontinuity problems. The angle is always stored and returned in the the range -pi,pi.