LogoPixi’VN
pixi-jsVariables

Variable: groupD8

> const groupD8: object

Defined in: node_modules/pixi.js/lib/maths/matrix/groupD8.d.ts:23

Implements the dihedral group D8, which is similar to [group D4]http://mathworld.wolfram.com/DihedralGroupD4.html; D8 is the same but with diagonals, and it is used for texture rotations.

The directions the U- and V- axes after rotation of an angle of a: GD8Constant are the vectors (uX(a), uY(a)) and (vX(a), vY(a)). These aren't necessarily unit vectors.

Type Declaration

add

> add: (rotationSecond, rotationFirst) => GD8Symmetry

Composes the two D8 operations.

Taking ^ as reflection:

| | E=0 | S=2 | W=4 | N=6 | E^=8 | S^=10 | W^=12 | N^=14 | |-------|-----|-----|-----|-----|------|-------|-------|-------| | E=0 | E | S | W | N | E^ | S^ | W^ | N^ | | S=2 | S | W | N | E | S^ | W^ | N^ | E^ | | W=4 | W | N | E | S | W^ | N^ | E^ | S^ | | N=6 | N | E | S | W | N^ | E^ | S^ | W^ | | E^=8 | E^ | N^ | W^ | S^ | E | N | W | S | | S^=10 | S^ | E^ | N^ | W^ | S | E | N | W | | W^=12 | W^ | S^ | E^ | N^ | W | S | E | N | | N^=14 | N^ | W^ | S^ | E^ | N | W | S | E |

[This is a Cayley table]https://en.wikipedia.org/wiki/Cayley_table

Parameters

rotationSecond

GD8Symmetry

Second operation, which is the row in the above cayley table.

rotationFirst

GD8Symmetry

First operation, which is the column in the above cayley table.

Returns

GD8Symmetry

Composed operation

byDirection

> byDirection: (dx, dy) => GD8Symmetry

Approximates the vector V(dx,dy) into one of the eight directions provided by groupD8.

Parameters

dx

number

X-component of the vector

dy

number

Y-component of the vector

Returns

GD8Symmetry

Approximation of the vector into one of the eight symmetries.

E

> E: number

| Rotation | Direction | |----------|-----------| | 0° | East |

inv

> inv: (rotation) => GD8Symmetry

Parameters

rotation

GD8Symmetry

symmetry whose opposite is needed. Only rotations have opposite symmetries while reflections don't.

Returns

GD8Symmetry

The opposite symmetry of rotation

isVertical

> isVertical: (rotation) => boolean

Checks if the rotation angle is vertical, i.e. south or north. It doesn't work for reflections.

Parameters

rotation

GD8Symmetry

The number to check.

Returns

boolean

Whether or not the direction is vertical

MAIN_DIAGONAL

> MAIN_DIAGONAL: number

Reflection about the main diagonal.

matrixAppendRotationInv

> matrixAppendRotationInv: (matrix, rotation, tx?, ty?, dw?, dh?) => void

Helps sprite to compensate texture packer rotation.

Parameters

matrix

Matrix

sprite world matrix

rotation

GD8Symmetry

The rotation factor to use.

tx?

number

sprite anchoring

ty?

number

sprite anchoring

dw?

number

sprite width

dh?

number

sprite height

Returns

void

MIRROR_HORIZONTAL

> MIRROR_HORIZONTAL: number

Reflection about X-axis.

MIRROR_VERTICAL

> MIRROR_VERTICAL: number

Reflection about Y-axis.

N

> N: number

| Rotation | Direction | |-------------|--------------| | -90°/270°↻ | North |

NE

> NE: number

| Rotation | Direction | |-------------|--------------| | -45°/315°↻ | Northeast |

NW

> NW: number

| Rotation | Direction | |-------------|--------------| | -135°/225°↻ | Northwest |

REVERSE_DIAGONAL

> REVERSE_DIAGONAL: number

Reflection about reverse diagonal.

rotate180

> rotate180: (rotation) => number

Adds 180 degrees to rotation, which is a commutative operation.

Parameters

rotation

number

The number to rotate.

Returns

number

Rotated number

S

> S: number

| Rotation | Direction | |----------|-----------| | 90°↻ | South |

SE

> SE: number

| Rotation | Direction | |----------|-----------| | 45°↻ | Southeast |

sub

> sub: (rotationSecond, rotationFirst) => GD8Symmetry

Reverse of add.

Parameters

rotationSecond

GD8Symmetry

Second operation

rotationFirst

GD8Symmetry

First operation

Returns

GD8Symmetry

Result

SW

> SW: number

| Rotation | Direction | |----------|-----------| | 135°↻ | Southwest |

transformRectCoords

> transformRectCoords: (rect, sourceFrame, rotation, out) => Rectangle

Transforms rectangle coordinates based on texture packer rotation. Used when texture atlas pages are rotated and coordinates need to be adjusted.

Parameters

rect

RectangleLike

Rectangle with original coordinates to transform

sourceFrame

RectangleLike

Source texture frame (includes offset and dimensions)

rotation

GD8Symmetry

The groupD8 rotation value

out

Rectangle

Rectangle to store the result

Returns

Rectangle

Transformed coordinates (includes source frame offset)

uX

> uX: (ind) => GD8Symmetry

Parameters

ind

GD8Symmetry

sprite rotation angle.

Returns

GD8Symmetry

The X-component of the U-axis after rotating the axes.

uY

> uY: (ind) => GD8Symmetry

Parameters

ind

GD8Symmetry

sprite rotation angle.

Returns

GD8Symmetry

The Y-component of the U-axis after rotating the axes.

vX

> vX: (ind) => GD8Symmetry

Parameters

ind

GD8Symmetry

sprite rotation angle.

Returns

GD8Symmetry

The X-component of the V-axis after rotating the axes.

vY

> vY: (ind) => GD8Symmetry

Parameters

ind

GD8Symmetry

sprite rotation angle.

Returns

GD8Symmetry

The Y-component of the V-axis after rotating the axes.

W

> W: number

| Rotation | Direction | |----------|-----------| | 180° | West |

Author

Ivan: ivanpopelyshev

Advanced