Search in sources :

Example 6 with Transform

use of spacegraph.space2d.phys.common.Transform in project narchy by automenta.

the class PolygonShape method setAsBox.

/**
 * Build vertices to represent an oriented box.
 *
 * @param hx     the half-width.
 * @param hy     the half-height.
 * @param center the center of the box in local coordinates.
 * @param angle  the rotation of the box in local coordinates.
 */
public final PolygonShape setAsBox(final float hx, final float hy, final Tuple2f center, final float angle) {
    vertices = 4;
    vertex[0].set(-hx, -hy);
    vertex[1].set(hx, -hy);
    vertex[2].set(hx, hy);
    vertex[3].set(-hx, hy);
    normals[0].set(0.0f, -1.0f);
    normals[1].set(1.0f, 0.0f);
    normals[2].set(0.0f, 1.0f);
    normals[3].set(-1.0f, 0.0f);
    centroid.set(center);
    final Transform xf = poolt1;
    xf.pos.set(center);
    xf.set(angle);
    // Transform vertices and normals.
    for (int i = 0; i < vertices; ++i) {
        Transform.mulToOut(xf, vertex[i], vertex[i]);
        Rot.mulToOut(xf, normals[i], normals[i]);
    }
    return this;
}
Also used : Transform(spacegraph.space2d.phys.common.Transform)

Example 7 with Transform

use of spacegraph.space2d.phys.common.Transform in project narchy by automenta.

the class Diffusion method focee.

@Override
public Tuple2f[] focee(Tuple2f startPoint, Tuple2f vektor) {
    // pocet
    final int count = 128;
    // natiahnutie
    double c = 4;
    // vektor = new v2(1, 0);
    float ln = vektor.length();
    Transform t = new Transform();
    t.set(startPoint, 0);
    t.c = vektor.y / ln;
    t.s = vektor.x / ln;
    Tuple2f[] va = new Tuple2f[count];
    for (int i = 1; i <= count; i++) {
        double a = r.nextFloat() * 2 * Math.PI;
        double d = -Math.log(r.nextFloat()) * m_shattering;
        double x = Math.sin(a) * d;
        double y = Math.cos(a) * d * c;
        Tuple2f v = new v2((float) x, (float) y);
        va[i - 1] = Transform.mul(t, v);
    }
    return va;
}
Also used : Tuple2f(spacegraph.util.math.Tuple2f) Transform(spacegraph.space2d.phys.common.Transform) spacegraph.util.math.v2(spacegraph.util.math.v2)

Aggregations

Transform (spacegraph.space2d.phys.common.Transform)7 Tuple2f (spacegraph.util.math.Tuple2f)3 spacegraph.util.math.v2 (spacegraph.util.math.v2)3 Rot (spacegraph.space2d.phys.common.Rot)2 ContactID (spacegraph.space2d.phys.collision.ContactID)1 ManifoldPoint (spacegraph.space2d.phys.collision.ManifoldPoint)1 PolygonShape (spacegraph.space2d.phys.collision.shapes.PolygonShape)1 Shape (spacegraph.space2d.phys.collision.shapes.Shape)1 Body2D (spacegraph.space2d.phys.dynamics.Body2D)1 PolygonFixture (spacegraph.space2d.phys.fracture.PolygonFixture)1