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;
}
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;
}
Aggregations