Struct physics2d::Transform [] [src]

pub struct Transform {
    pub position: Vec2,
    // some fields omitted
}

Fields

Methods

impl Transform
[src]

[src]

[src]

[src]

[src]

Returns the world space position for the given local space position with respect to this Transform.

The local space position is first rotated by the world space rotation matrix and then translated by the world space position.

Examples


let t = Transform::new(Vec2::new(1.0, 2.0), math::PI / 2.0);

assert_eq!(t.world_pos(&Vec2::ZERO), Vec2::new(1.0, 2.0));
assert_eq!(t.world_pos(&Vec2::new(1.0, 1.0)), Vec2::new(0.0, 3.0));

[src]

Returns the world space direction for the given local space direction with respect to this Transform.

The local space direction is rotated by the world space rotation matrix.

Examples


let t = Transform::new(Vec2::new(1000.01, 333.333), math::PI / 2.0);

assert!((t.world_dir(&Vec2::RIGHT) - Vec2::UP).len() < 1e-07);

[src]

Returns the local space position with respect to this Transform for the given world space position.

The world space position is first brought relative to the local origin and then rotated to be relative to the local space rotation.

Examples


let t = Transform::new(Vec2::new(1.0, 2.0), math::PI / 2.0);

assert_eq!(t.local_pos(&Vec2::new(1.0, 2.0)), Vec2::ZERO);
assert!((t.local_pos(&Vec2::new(1.0, 3.0)) - Vec2::new(1.0, 0.0)).len() < 1e-07);

[src]

Returns the local space direction with respect to this Transform for the given world space direction.

The world space direction is rotated to be relative to the local space rotation.

Examples


let t = Transform::new(Vec2::new(1000.01, 333.333), math::PI / 2.0);

assert!((t.local_dir(&Vec2::UP) - Vec2::RIGHT).len() < 1e-07);