APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.physics.box2d

public Class Transform

extends Object
Class Inheritance
Imports
com.badlogic.gdx.math.Vector2

Encodes a Box2D transform. We are lazy so we only store a 4 float wide array. First two floats are the position of the b2Transform struct. Next two floats are the cosine and sine of the rotation angle.
Author
mzechner

Field Summary

Modifier and TypeField and Description
public static final int
private Vector2
public static final int
public static final int
private Vector2
public static final int
public float[]

Constructor Summary

AccessConstructor and Description
public
public
Transform(Vector2
the position
position
,
float
the angle in radians
angle
)

Constructs a new Transform instance with the given position and angle

public
Transform(Vector2
the position
position
,
Vector2
where the transform is pointing
orientation
)

Constructs a new Transform instance with the given position and orientation

Method Summary

Modifier and TypeMethod and Description
public Vector2
getOrientation()

Returns: A vector 2 pointing to where the body is facing

public Vector2
getPosition()

Returns: the position, modification of the vector has no effect on the Transform

public float
public Vector2
mul(Vector2
the vector
v
)

Transforms the given vector by this transform

public void
setOrientation(Vector2 orientation)

Set where the body should "look at"

public void
setPosition(Vector2
the position
pos
)

Sets the position of this transform

public void
setRotation(float
angle in radians
angle
)

Sets the rotation of this transform

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COSback to summary
public static final int COS
orientationback to summary
private Vector2 orientation
POS_Xback to summary
public static final int POS_X
POS_Yback to summary
public static final int POS_Y
positionback to summary
private Vector2 position
SINback to summary
public static final int SIN
valsback to summary
public float[] vals

Constructor Detail

Transformback to summary
public Transform()
Transformback to summary
public Transform(Vector2 position, float angle)

Constructs a new Transform instance with the given position and angle

Parameters
position:Vector2

the position

angle:float

the angle in radians

Transformback to summary
public Transform(Vector2 position, Vector2 orientation)

Constructs a new Transform instance with the given position and orientation

Parameters
position:Vector2

the position

orientation:Vector2

where the transform is pointing

Method Detail

getOrientationback to summary
public Vector2 getOrientation()
Returns:Vector2

A vector 2 pointing to where the body is facing

getPositionback to summary
public Vector2 getPosition()
Returns:Vector2

the position, modification of the vector has no effect on the Transform

getRotationback to summary
public float getRotation()
mulback to summary
public Vector2 mul(Vector2 v)

Transforms the given vector by this transform

Parameters
v:Vector2

the vector

setOrientationback to summary
public void setOrientation(Vector2 orientation)

Set where the body should "look at"

setPositionback to summary
public void setPosition(Vector2 pos)

Sets the position of this transform

Parameters
pos:Vector2

the position

setRotationback to summary
public void setRotation(float angle)

Sets the rotation of this transform

Parameters
angle:float

angle in radians